blob: a69b1cf64f91f379247b3d9a98d20f4375f04feb [file] [log] [blame]
PGlazovccae4142021-06-29 17:09:05 +04001# export REMOTE_JENKINS='172.19.112.216'
2export REMOTE_JENKINS='sre-ci.scc.mirantis.net'
3
4if [ ! -n "$LAB_CONTEXT_NAME" ]; then
5 echo 'LAB_CONTEXT_NAME is not set!
6 This name will be used:
7 - to find the template file tcp_tests/templates/cookied-model-generator/salt_${LAB_CONTEXT_NAME}.yaml
8 - to set the salt model cluster name
9 - to make DOMAIN_NAME=${LAB_CONTEXT_NAME}.local
10 ';
11 exit 1
12fi
13
14
15if [ -n "$TCP_QA_REVIEW" ]; then
16 git fetch https://gerrit.mcp.mirantis.com/mcp/tcp-qa $TCP_QA_REVIEW && git checkout FETCH_HEAD
17fi
18
19. ${VENV_PATH}/bin/activate
20
21if [ "$ERASE_EXISTING_ENVIRONMENT" = "true" ]; then
22 dos.py erase $ENV_NAME || true
23fi
24
25cd tcp_tests
26
27rm -f ./*.tar.gz
28
29#MODEL_FILENAME=model_${CLUSTER_NAME}_${BUILD_NUMBER}.tar.gz
30MODEL_FILENAME=model_${ENV_NAME}.tar.gz
31if [[ -f $MODEL_FILENAME ]]; then
32 rm $MODEL_FILENAME
33fi
34
35####################
36# Generate the model
37
38py.test --junit-xml=deploy_generate_model.xml -k ${TEST_GROUP}
39
40
41########################################################
42# Upload the generated model to the repository on cz8133
43
44# Create a directory where the created model will be unpacked
45rm -rf ./model
46mkdir -p ./model
47
48eval $(ssh-agent)
49ssh-add ${SSH_PRIVATE_KEY}
50
51# Create remote repository
52ssh jenkins@${REMOTE_JENKINS} "
53 if [[ ! -d /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git ]]; then
54 mkdir -p /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
55 cd /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
56 git init --bare;
57 cp hooks/post-update.sample hooks/post-update;
58 fi"
59
60cd ./model
61
62# Prepare the repository in the ./model
63git init
64git remote add integration ssh://jenkins@${REMOTE_JENKINS}/home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git
65git pull integration ${REPOSITORY_SUITE} || true
66git checkout -b ${REPOSITORY_SUITE}
67git rm -rf . || true # remove previous content from the working dir
68
69# unpack new model into ./model dir
70tar -xzf ../${MODEL_FILENAME} -C ./
71# Add reclass-system submodule
72git submodule add https://gerrit.mcp.mirantis.com/salt-models/reclass-system classes/system/
73cd classes/system
74git checkout ${SALT_MODELS_SYSTEM_COMMIT}
75cd ../..
76
77# The directory "classes/service" is created at bootstrap time
78# and cannot be commited to the repository automatically.
79# It is not needed in the repo because contains only symlinks.
80cat << EOF > ./.gitignore
81classes/service
82EOF
83
84# create a commit with new model (if any change exists)
85git add -A
86git commit -m "${LAB_CONTEXT_NAME}@${REPOSITORY_SUITE} generated at $(date +%Y-%m-%d/%H-%M)
87
88REPOSITORY_SUITE=${REPOSITORY_SUITE}
89SALT_MODELS_SYSTEM_COMMIT=${SALT_MODELS_SYSTEM_COMMIT}
90COOKIECUTTER_TEMPLATE_COMMIT=${COOKIECUTTER_TEMPLATE_COMMIT}
91"
92
93# Push new commit to the ${REMOTE_JENKINS} repository
94git push integration ${REPOSITORY_SUITE}
95
96echo "######################################################################################################################"
97echo "#"
98echo "# Clone the model into the tests: git clone http://${REMOTE_JENKINS}:8098/${LAB_CONTEXT_NAME}.git -b ${REPOSITORY_SUITE}"
99echo "#"
100echo "######################################################################################################################"
101