blob: 3dd9b3ca0012fa01eac35c1b06eb44bed0867410 [file] [log] [blame]
Anna Arhipovad2ced492022-09-28 10:02:56 +02001# 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
27sed -i 's/%LOGIN%/rHm22xBV9K/' templates/${LAB_CONTEXT_NAME}/salt-context-cookiecutter*
28sed -i 's/%PASS%/az9Gq7Wq4jRic29YWP/' templates/${LAB_CONTEXT_NAME}/salt-context-cookiecutter*
29
30rm -f ./*.tar.gz
31
32#MODEL_FILENAME=model_${CLUSTER_NAME}_${BUILD_NUMBER}.tar.gz
33MODEL_FILENAME=model_${ENV_NAME}.tar.gz
34if [[ -f $MODEL_FILENAME ]]; then
35 rm $MODEL_FILENAME
36fi
37
38####################
39# Generate the model
40git config user.name "tester"
41git config user.email "tester@example.com"
42
43py.test --junit-xml=deploy_generate_model.xml -k ${TEST_GROUP}
44
45
46########################################################
47# Upload the generated model to the repository on cz8133
48
49# Create a directory where the created model will be unpacked
50rm -rf ./model
51mkdir -p ./model
52
53eval $(ssh-agent)
54ssh-add ${COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH}
55
56# Create remote repository
57ssh jenkins@${REMOTE_JENKINS} "
58 if [[ ! -d /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git ]]; then
59 mkdir -p /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
60 cd /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
61 git init --bare;
62 cp hooks/post-update.sample hooks/post-update;
63 fi"
64
65cd ./model
66
67# Prepare the repository in the ./model
68git init
69git remote add integration ssh://jenkins@${REMOTE_JENKINS}/home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git
70git pull integration ${REPOSITORY_SUITE} || true
71git checkout -b ${REPOSITORY_SUITE}
72git rm -rf . || true # remove previous content from the working dir
73
74# unpack new model into ./model dir
75tar -xzf ../${MODEL_FILENAME} -C ./
76# Add reclass-system submodule
77git submodule add https://gerrit.mcp.mirantis.com/salt-models/reclass-system classes/system/
78cd classes/system
79git checkout ${SALT_MODELS_SYSTEM_COMMIT}
80cd ../..
81
82# The directory "classes/service" is created at bootstrap time
83# and cannot be commited to the repository automatically.
84# It is not needed in the repo because contains only symlinks.
85cat << EOF > ./.gitignore
86classes/service
87EOF
88
89# create a commit with new model (if any change exists)
90git add -A
91git commit -m "${LAB_CONTEXT_NAME}@${REPOSITORY_SUITE} generated at $(date +%Y-%m-%d/%H-%M)
92
93REPOSITORY_SUITE=${REPOSITORY_SUITE}
94SALT_MODELS_SYSTEM_COMMIT=${SALT_MODELS_SYSTEM_COMMIT}
95COOKIECUTTER_TEMPLATE_COMMIT=${COOKIECUTTER_TEMPLATE_COMMIT}
96"
97
98# Push new commit to the ${REMOTE_JENKINS} repository
99git push integration ${REPOSITORY_SUITE}
100
101echo "######################################################################################################################"
102echo "#"
103echo "# Clone the model into the tests: git clone http://${REMOTE_JENKINS}:8098/${LAB_CONTEXT_NAME}.git -b ${REPOSITORY_SUITE}"
104echo "#"
105echo "######################################################################################################################"
106