forked from pulp/pulp_file
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·219 lines (180 loc) · 8.56 KB
/
Copy pathscript.sh
File metadata and controls
executable file
·219 lines (180 loc) · 8.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/env bash
# coding=utf-8
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_file' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../../..
REPO_ROOT="$PWD"
set -mveuo pipefail
source .github/workflows/scripts/utils.sh
export POST_SCRIPT=$PWD/.github/workflows/scripts/post_script.sh
export POST_DOCS_TEST=$PWD/.github/workflows/scripts/post_docs_test.sh
export FUNC_TEST_SCRIPT=$PWD/.github/workflows/scripts/func_test_script.sh
# Needed for both starting the service and building the docs.
# Gets set in .github/settings.yml, but doesn't seem to inherited by
# this script.
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
export PULP_SETTINGS=$PWD/.ci/ansible/settings/settings.py
export PULP_URL="https://pulp"
if [[ "$TEST" = "docs" ]]; then
if [[ "$GITHUB_WORKFLOW" == "File CI" ]]; then
pip install towncrier==19.9.0
towncrier --yes --version 4.0.0.ci
fi
cd docs
make PULP_URL="$PULP_URL" diagrams html
tar -cvf docs.tar ./_build
cd ..
if [ -f $POST_DOCS_TEST ]; then
source $POST_DOCS_TEST
fi
exit
fi
if [[ "${RELEASE_WORKFLOW:-false}" == "true" ]]; then
STATUS_ENDPOINT="${PULP_URL}${PULP_API_ROOT}api/v3/status/"
echo $STATUS_ENDPOINT
REPORTED_VERSION=$(http $STATUS_ENDPOINT | jq --arg plugin file --arg legacy_plugin pulp_file -r '.versions[] | select(.component == $plugin or .component == $legacy_plugin) | .version')
response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-file/$REPORTED_VERSION/)
if [ "$response" == "200" ];
then
echo "pulp_file $REPORTED_VERSION has already been released. Skipping running tests."
exit
fi
fi
if [[ "$TEST" == "plugin-from-pypi" ]]; then
COMPONENT_VERSION=$(http https://pypi.org/pypi/pulp-file/json | jq -r '.info.version')
git checkout ${COMPONENT_VERSION} -- pulp_file/tests/
fi
cat unittest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt"
cat functest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt"
cmd_prefix pip3 install -r /tmp/unittest_requirements.txt
cmd_prefix pip3 install -r /tmp/functest_requirements.txt
cmd_prefix pip3 install --upgrade ../pulp-smash
cd ../pulp-openapi-generator
./generate.sh pulp_file python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulp_file-client
sudo rm -rf ./pulp_file-client
./generate.sh pulpcore python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulpcore-client
sudo rm -rf ./pulpcore-client
if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulpcore ruby 0
cd pulpcore-client
gem build pulpcore_client.gemspec
cmd_prefix gem install --both /root/pulp-openapi-generator/pulpcore-client/pulpcore_client-0.gem
fi
./generate.sh pulp_certguard python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulp_certguard-client
sudo rm -rf ./pulp_certguard-client
if [[ "$TEST" = 'bindings' ]]; then
./generate.sh pulp-certguard ruby 0
cd pulp-certguard-client
gem build pulp-certguard_client.gemspec
cmd_prefix gem install --both /root/pulp-openapi-generator/pulp-certguard-client/pulp-certguard_client-0.gem
cd ..
fi
cd $REPO_ROOT
if [[ "$TEST" = 'bindings' ]]; then
if [ -f $REPO_ROOT/.ci/assets/bindings/test_bindings.py ]; then
python $REPO_ROOT/.ci/assets/bindings/test_bindings.py
fi
if [ -f $REPO_ROOT/.ci/assets/bindings/test_bindings.rb ]; then
ruby $REPO_ROOT/.ci/assets/bindings/test_bindings.rb
fi
exit
fi
CERTIFI=$(cmd_prefix python3 -c 'import certifi; print(certifi.where())')
cmd_prefix bash -c "cat /etc/pulp/certs/pulp_webserver.crt | tee -a "$CERTIFI" > /dev/null"
# check for any uncommitted migrations
echo "Checking for uncommitted migrations..."
cmd_prefix bash -c "django-admin makemigrations --check --dry-run"
if [[ "$TEST" != "upgrade" ]]; then
# Run unit tests.
cmd_prefix bash -c "PULP_DATABASES__default__USER=postgres pytest -v -r sx --color=yes -p no:pulpcore --pyargs pulp_file.tests.unit"
fi
# Run functional tests
if [[ "$TEST" == "upgrade" ]]; then
# Handle app label change:
sed -i "/require_pulp_plugins(/d" pulp_file/tests/functional/utils.py
# Running pre upgrade tests:
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs --capture=no pulp_file.tests.upgrade.pre"
# Checking out ci_upgrade_test branch and upgrading plugins
cmd_prefix bash -c "cd pulpcore; git checkout -f ci_upgrade_test; pip install --upgrade --force-reinstall ."
cmd_prefix bash -c "cd pulp-certguard; git checkout -f ci_upgrade_test; pip install ."
cmd_prefix bash -c "cd pulp_file; git checkout -f ci_upgrade_test; pip install ."
# Migrating
cmd_prefix bash -c "django-admin migrate --no-input"
# Restarting single container services
cmd_prefix bash -c "s6-svc -r /var/run/s6/services/pulpcore-api"
cmd_prefix bash -c "s6-svc -r /var/run/s6/services/pulpcore-content"
cmd_prefix bash -c "s6-svc -d /var/run/s6/services/pulpcore-resource-manager"
cmd_prefix bash -c "s6-svc -d /var/run/s6/services/pulpcore-worker@1"
cmd_prefix bash -c "s6-svc -d /var/run/s6/services/pulpcore-worker@2"
cmd_prefix bash -c "s6-svc -u /var/run/s6/services/new-pulpcore-resource-manager"
cmd_prefix bash -c "s6-svc -u /var/run/s6/services/new-pulpcore-worker@1"
cmd_prefix bash -c "s6-svc -u /var/run/s6/services/new-pulpcore-worker@2"
echo "Restarting in 60 seconds"
sleep 60
# Let's reinstall pulpcore so we can ensure we have the correct dependencies
cd ../pulpcore
git checkout -f ci_upgrade_test
pip install --upgrade --force-reinstall . ../pulp-cli ../pulp-smash
# Hack: adding pulp CA to certifi.where()
CERTIFI=$(python -c 'import certifi; print(certifi.where())')
cat /usr/local/share/ca-certificates/pulp_webserver.crt | sudo tee -a "$CERTIFI" > /dev/null
# CLI commands to display plugin versions and content data
pulp status
pulp content list
CONTENT_LENGTH=$(pulp content list | jq length)
if [[ "$CONTENT_LENGTH" == "0" ]]; then
echo "Empty content list"
exit 1
fi
# Rebuilding bindings
cd ../pulp-openapi-generator
./generate.sh pulpcore python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulpcore-client
./generate.sh pulp_file python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulp_file-client
./generate.sh pulp_certguard python
cmd_prefix pip3 install /root/pulp-openapi-generator/pulp_certguard-client
cd $REPO_ROOT
# Running post upgrade tests
git checkout ci_upgrade_test -- pulp_file/tests/
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs --capture=no pulp_file.tests.upgrade.post"
exit
fi
if [[ "$TEST" == "performance" ]]; then
if [[ -z ${PERFORMANCE_TEST+x} ]]; then
cmd_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance"
else
cmd_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_file.tests.performance.test_$PERFORMANCE_TEST"
fi
exit
fi
if [ -f $FUNC_TEST_SCRIPT ]; then
source $FUNC_TEST_SCRIPT
else
if [[ "$GITHUB_WORKFLOW" == "File Nightly CI/CD" ]]; then
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m parallel -n 8"
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel'"
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and parallel' -n 8"
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not parallel'"
else
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_file.tests.functional -m 'parallel and not nightly' -n 8"
cmd_prefix bash -c "pytest -v -r sx --color=yes --pyargs pulp_file.tests.functional -m 'not parallel and not nightly'"
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not nightly and parallel' -n 8"
cmd_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulpcore.tests.functional -m 'from_pulpcore_for_all_plugins and not nightly and not parallel'"
fi
fi
export PULP_FIXTURES_URL="http://pulp-fixtures:8080"
pushd ../pulp-cli
pytest -v -m pulp_file
popd
if [ -f $POST_SCRIPT ]; then
source $POST_SCRIPT
fi