Add fail scenarios in csit
[policy/docker.git] / csit / resources / scripts / build-csit-docker-image.sh
1 #!/bin/bash -x
2 #
3 # Copyright 2024 Nordix Foundation.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 function clone_models() {
18     # download models examples
19     git clone -b "${GERRIT_BRANCH}" --single-branch https://github.com/onap/policy-models.git "${WORKSPACE}"/csit/resources/tests/models
20
21     # create a couple of variations of the policy definitions
22     sed -e 's!Measurement_vGMUX!ADifferentValue!' \
23         tests/models/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json \
24         >tests/models/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.v1_2.json
25
26     sed -e 's!"version": "1.0.0"!"version": "2.0.0"!' \
27         -e 's!"policy-version": 1!"policy-version": 2!' \
28         tests/models/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.json \
29         >tests/models/models-examples/src/main/resources/policies/vCPE.policy.monitoring.input.tosca.v2.json
30 }
31
32 if [ -z "${WORKSPACE}" ]; then
33     WORKSPACE=$(git rev-parse --show-toplevel)
34     export WORKSPACE
35 fi
36
37 GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' "${WORKSPACE}"/.gitreview)
38 export ROBOT_DOCKER_IMAGE="policy-csit-robot"
39
40 echo "Build docker image for robot framework"
41 cd ${WORKSPACE}/csit/resources || exit
42
43 docker image rm -f ${ROBOT_DOCKER_IMAGE}
44
45 # get models
46 clone_models
47
48 echo "Build robot framework docker image"
49 docker build . --file Dockerfile  --tag "${ROBOT_DOCKER_IMAGE}"  --no-cache
50 docker save -o policy-csit-robot.tar ${ROBOT_DOCKER_IMAGE}:latest
51
52 rm -rf ${WORKSPACE}/csit/resources/policy-csit-robot.tar
53 rm -rf ${WORKSPACE}/csit/resources/tests/models/