@@ -11,11 +11,75 @@ workflow:
11
11
- when : always
12
12
13
13
variables :
14
- POSTGRES_DB : dbname # set database
15
- POSTGRES_USER : test_user # set username
14
+ POSTGRES_DB : dbname # Set database.
15
+ POSTGRES_USER : test_user # Set username.
16
16
POSTGRES_PASSWORD : " "
17
17
POSTGRES_HOST_AUTH_METHOD : " trust"
18
18
19
+ test-general :
20
+ stage : test
21
+ before_script :
22
+ - apt-get update
23
+ - apt-get install -y jq curl wget git s3cmd sudo golang-1.9-go git
24
+ - echo "export PATH=\$PATH:/usr/lib/go-1.9/bin" >> ~/.profile
25
+ - source ~/.profile
26
+ - cd ./pghrep && make install main && cd ..
27
+ - sudo .ci/prepare_cluster.sh "11"
28
+ - ps ax | grep postgres
29
+ - psql -U postgres -p 5432 -c 'show data_directory;'
30
+ - psql -U postgres -p 5433 -c 'show data_directory;'
31
+ - psql -U postgres -p 5434 -c 'show data_directory;'
32
+ # Configure ssh keys
33
+ - mkdir -p ~/.ssh && echo "${PRIVATE_KEY}" > ~/.ssh/id_rsa && echo "${PUBLIC_KEY}" > ~/.ssh/authorized_keys && echo "${PUBLIC_KEY}" > ~/.ssh/id_rsa.pub && chmod 644 ~/.ssh/authorized_keys && chmod 644 ~/.ssh/id_rsa.pub && chmod 600 ~/.ssh/id_rsa
34
+ - echo "${PRIVATE_KEY}" > ~/.ssh/gitlab_key && chmod 600 ~/.ssh/gitlab_key
35
+ - echo "Host gitlab.com" > ~/.ssh/config && echo " Preferredauthentications publickey" >> ~/.ssh/config && echo " IdentityFile ~/.ssh/gitlab_key" >> ~/.ssh/config
36
+ - apt-get -y install openssh-server
37
+ - service ssh restart
38
+
39
+ script :
40
+ - bash -version
41
+ - psql -d dbname -U test_user -c "SELECT version();"
42
+ - psql -p 5433 -d dbname -U test_user -c "SELECT version();"
43
+ - psql -p 5434 -d dbname -U test_user -c "SELECT version();"
44
+ - psql -d dbname -U test_user -f .ci/test_db_dump.sql
45
+ - .ci/prepare_test_db.sh
46
+ - vacuumdb -U test_user dbname --analyze
47
+ - export ARTIFACTS_PATH=$(pwd)/artifacts && echo $ARTIFACTS_PATH
48
+ # First run only for K00X reports
49
+ - ./checkup collect -h postgres.test1.node --pg-port 5433 --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
50
+ - ./checkup collect -h postgres.test2.node --pg-port 5434 --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
51
+ - ./checkup collect -h postgres.test3.node --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
52
+ # Last run of checkup
53
+ - ./checkup collect -h postgres.test1.node --pg-port 5433 --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
54
+ - ./checkup collect -h postgres.test2.node --pg-port 5434 --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
55
+ - ./checkup collect -h postgres.test3.node --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
56
+ - ./checkup process --project test
57
+ # Check results
58
+ - cat err.log
59
+ - grep -v "To compare results, 2 runs are needed. Please run './checkup collect' once again for this epoch." err.log > err1.log || true
60
+ - grep -v "this is not a real error. Just run check again." err1.log > err.log || true
61
+ - grep -v "Failed to create bus connection" err.log > err1.log || true
62
+ - cat err1.log
63
+ - export TEST_RESULT=$(stat --format="%s" err1.log) && echo $TEST_RESULT
64
+ - ([[ $TEST_RESULT -ne 0 ]]) && exit 1
65
+ -
(git config --global user.name "postgres-ai" && git config --global user.email "[email protected] " && git config --global push.default simple) || true
66
+ - eval $(ssh-agent -s) || true
67
+ - ssh-add ~/.ssh/gitlab_key || true
68
+ - ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts || true
69
+ -
ssh -T [email protected] || true
70
+ -
(cd ~/ && git clone [email protected] :postgres-ai-team/postgres-checkup-tests.git) || true
71
+ - (mkdir -p ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME && [[ "$CI_COMMIT_REF_NAME" != "master" ]] && rm -Rf ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME/*) || true
72
+ - (cp -Rf $ARTIFACTS_PATH/test/* ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME/) || true
73
+ - (cd ~/postgres-checkup-tests && git add ./$CI_COMMIT_REF_NAME/* && git commit -m "$CI_COMMIT_REF_NAME artifacts" && git push) || true
74
+ - exit $TEST_RESULT
75
+
76
+ artifacts :
77
+ paths :
78
+ - ./artifacts/test
79
+ - ./std.log
80
+ - ./err.log
81
+ expire_in : 1 week
82
+
19
83
.prepare :
20
84
stage : test
21
85
before_script :
@@ -29,6 +93,7 @@ variables:
29
93
- psql --version
30
94
- echo "export PATH=\$PATH:/usr/lib/go-1.9/bin" >> ~/.profile
31
95
- source ~/.profile
96
+ - cd ./pghrep && make install main && cd ..
32
97
33
98
.test-check :
34
99
stage : test
@@ -86,69 +151,6 @@ variables:
86
151
- data_dir=$(cat ./artifacts/test/nodes.json | jq -r '.last_check | .dir') && result=$(cat "./artifacts/test/json_reports/$data_dir/H004_redundant_indexes.json" | jq '.results .postgres .data .redundant_indexes ."public.i_r_12"') && ([[ ! "$result" == "[]" ]] && [[ ! "$result" == "null" ]]) && exit 213
87
152
- echo "Check small indexes in large db mode passed"
88
153
89
- test-general :
90
- stage : test
91
- before_script :
92
- - apt-get update
93
- - apt-get install -y jq curl wget git s3cmd sudo golang-1.9-go git
94
- - echo "export PATH=\$PATH:/usr/lib/go-1.9/bin" >> ~/.profile
95
- - source ~/.profile
96
- - sudo .ci/prepare_cluster.sh "11"
97
- - ps ax | grep postgres
98
- - psql -U postgres -p 5432 -c 'show data_directory;'
99
- - psql -U postgres -p 5433 -c 'show data_directory;'
100
- - psql -U postgres -p 5434 -c 'show data_directory;'
101
- # Configure ssh keys
102
- - mkdir -p ~/.ssh && echo "${PRIVATE_KEY}" > ~/.ssh/id_rsa && echo "${PUBLIC_KEY}" > ~/.ssh/authorized_keys && echo "${PUBLIC_KEY}" > ~/.ssh/id_rsa.pub && chmod 644 ~/.ssh/authorized_keys && chmod 644 ~/.ssh/id_rsa.pub && chmod 600 ~/.ssh/id_rsa
103
- - echo "${PRIVATE_KEY}" > ~/.ssh/gitlab_key && chmod 600 ~/.ssh/gitlab_key
104
- - echo "Host gitlab.com" > ~/.ssh/config && echo " Preferredauthentications publickey" >> ~/.ssh/config && echo " IdentityFile ~/.ssh/gitlab_key" >> ~/.ssh/config
105
- - apt-get -y install openssh-server
106
- - service ssh restart
107
-
108
- script :
109
- - bash -version
110
- - psql -d dbname -U test_user -c "SELECT version();"
111
- - psql -p 5433 -d dbname -U test_user -c "SELECT version();"
112
- - psql -p 5434 -d dbname -U test_user -c "SELECT version();"
113
- - psql -d dbname -U test_user -f .ci/test_db_dump.sql
114
- - .ci/prepare_test_db.sh
115
- - vacuumdb -U test_user dbname --analyze
116
- - export ARTIFACTS_PATH=$(pwd)/artifacts && echo $ARTIFACTS_PATH
117
- # First run only for K00X reports
118
- - ./checkup collect -h postgres.test1.node --pg-port 5433 --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
119
- - ./checkup collect -h postgres.test2.node --pg-port 5434 --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
120
- - ./checkup collect -h postgres.test3.node --username test_user --project test --dbname dbname -e 1 --file resources/checks/K000_query_analysis.sh > >(tee -a std.log) 2> >(tee -a err.log >&2)
121
- # Last run of checkup
122
- - ./checkup collect -h postgres.test1.node --pg-port 5433 --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
123
- - ./checkup collect -h postgres.test2.node --pg-port 5434 --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
124
- - ./checkup collect -h postgres.test3.node --username test_user --project test --dbname dbname -e 1 > >(tee -a std.log) 2> >(tee -a err.log >&2)
125
- - ./checkup process --project test
126
- # Check results
127
- - cat err.log
128
- - grep -v "To compare results, 2 runs are needed. Please run './checkup collect' once again for this epoch." err.log > err1.log || true
129
- - grep -v "this is not a real error. Just run check again." err1.log > err.log || true
130
- - grep -v "Failed to create bus connection" err.log > err1.log || true
131
- - cat err1.log
132
- - export TEST_RESULT=$(stat --format="%s" err1.log) && echo $TEST_RESULT
133
- - ([[ $TEST_RESULT -ne 0 ]]) && exit 1
134
- -
(git config --global user.name "postgres-ai" && git config --global user.email "[email protected] " && git config --global push.default simple) || true
135
- - eval $(ssh-agent -s) || true
136
- - ssh-add ~/.ssh/gitlab_key || true
137
- - ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts || true
138
- -
ssh -T [email protected] || true
139
- -
(cd ~/ && git clone [email protected] :postgres-ai-team/postgres-checkup-tests.git) || true
140
- - (mkdir -p ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME && [[ "$CI_COMMIT_REF_NAME" != "master" ]] && rm -Rf ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME/*) || true
141
- - (cp -Rf $ARTIFACTS_PATH/test/* ~/postgres-checkup-tests/$CI_COMMIT_REF_NAME/) || true
142
- - (cd ~/postgres-checkup-tests && git add ./$CI_COMMIT_REF_NAME/* && git commit -m "$CI_COMMIT_REF_NAME artifacts" && git push) || true
143
- - exit $TEST_RESULT
144
-
145
- artifacts :
146
- paths :
147
- - ./artifacts/test
148
- - ./std.log
149
- - ./err.log
150
- expire_in : 1 week
151
-
152
154
test-pghrep :
153
155
stage : test
154
156
extends : " .prepare"
@@ -162,7 +164,7 @@ test-check-9.6:
162
164
- postgres:9.6
163
165
164
166
test-check-10 :
165
- extends : " .test-check"
167
+ extends : " .test-check"
166
168
stage : " test"
167
169
services :
168
170
- postgres:10
@@ -226,9 +228,9 @@ test-check-cli:
226
228
227
229
.only_var_template : &only_feature
228
230
rules :
229
- - if : $CI_COMMIT_REF_SLUG != "master" # $CI_COMMIT_REF_SLUG &&
231
+ - if : $CI_COMMIT_REF_SLUG && $CI_COMMIT_REF_SLUG != "master"
230
232
231
- build-image-feature-server :
233
+ build-image-feature :
232
234
<< : *build_image_definition
233
235
<< : *only_feature
234
236
variables :
@@ -238,14 +240,14 @@ build-image-feature-server:
238
240
DOCKER_NAME : " registry.gitlab.com/postgres-ai/postgres-checkup"
239
241
TAGS : " ${DOCKER_NAME}:${CI_COMMIT_REF_SLUG}"
240
242
241
- build-image-master-server :
243
+ build-image-master :
242
244
<< : *build_image_definition
243
245
<< : *only_master
244
246
variables :
245
247
DOCKER_NAME : " registry.gitlab.com/postgres-ai/postgres-checkup"
246
248
TAGS : " ${DOCKER_NAME}:master,${DOCKER_NAME}:master-${CI_COMMIT_SHORT_SHA}"
247
249
248
- build-image-latest-server :
250
+ build-image-latest :
249
251
<< : *build_image_definition
250
252
<< : *only_tag_release
251
253
variables :
@@ -255,7 +257,7 @@ build-image-latest-server:
255
257
DOCKER_NAME : " postgresai/postgres-checkup"
256
258
TAGS : " ${DOCKER_NAME}:latest,${DOCKER_NAME}:${CI_COMMIT_TAG}"
257
259
258
- build-image-rc-server :
260
+ build-image-rc :
259
261
<< : *build_image_definition
260
262
<< : *only_tag_rc
261
263
variables :
0 commit comments