Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.gitlab-ci.yml « test-on-gdk « ci « .gitlab - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 186025eff7143c0827db8db658db0db5b927c7d6 (plain)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
include:
  - local: .gitlab/ci/global.gitlab-ci.yml
  - local: .gitlab/ci/qa-common/main.gitlab-ci.yml
  - local: .gitlab/ci/qa-common/rules.gitlab-ci.yml
  - local: .gitlab/ci/qa-common/variables.gitlab-ci.yml

# code pattern changes
.code-pattern-changes: &code-pattern-changes
  if: $MR_CODE_PATTERNS == "true"

# Run all tests when QA framework changes present, full suite execution is explicitly enabled or a feature flag file is removed
.qa-run-all-tests: &qa-run-all-tests
  if: $QA_FRAMEWORK_CHANGES == "true" || $QA_RUN_ALL_TESTS == "true" || $QA_RUN_ALL_E2E_LABEL == "true" || $QA_FEATURE_FLAGS =~ /deleted/

.rules:gdk:qa-selective:
  rules:
    - <<: *code-pattern-changes
      when: never
    - !reference [.rules:test:qa-selective, rules]
    - if: $QA_SUITES =~ /Test::Instance::Blocking/

.rules:gdk:qa-parallel:
  rules:
    - <<: *code-pattern-changes
      variables:
        QA_TESTS: ""
          # To account for cases where a group label is set which may trigger selective execution
          # But we want to execute full reliable suite on gdk in case of code-pattern-changes
    - !reference [.rules:test:qa-parallel, rules]
    - if: $QA_SUITES =~ /Test::Instance::Blocking/
    - !reference [.rules:test:manual, rules]

.rules:gdk:qa-smoke:
  rules:
    - <<: *code-pattern-changes
      variables:
        QA_TESTS: ""
    - <<: *qa-run-all-tests
      variables:
        QA_TESTS: ""
    - if: $QA_SUITES =~ /Test::Instance::Smoke/
    - !reference [.rules:test:manual, rules]

.gdk-qa-base:
  image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/gitlab-build-images/debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}:bundler-${BUNDLER_VERSION}-git-2.36-lfs-2.9-chrome-${CHROME_VERSION}-docker-${DOCKER_VERSION}-gcloud-383-kubectl-1.23
  extends:
    - .qa-cache
    - .default-retry
  stage: test
  services:
    - docker:${DOCKER_VERSION}-dind
  tags:
    - e2e
  variables:
    DOCKER_HOST: tcp://docker:2375
    QA_GENERATE_ALLURE_REPORT: "true"
    QA_CAN_TEST_PRAEFECT: "false"
    QA_INTERCEPT_REQUESTS: "false"
    GITLAB_QA_ADMIN_ACCESS_TOKEN: $QA_ADMIN_ACCESS_TOKEN
    RSPEC_REPORT_OPTS: "--order random --force-color --format documentation --format RspecJunitFormatter --out tmp/rspec-${CI_JOB_ID}.xml --format QA::Support::JsonFormatter --out tmp/rspec-${CI_JOB_ID}.json  --format html --out tmp/rspec-${CI_JOB_ID}.htm"
    FF_NETWORK_PER_BUILD: 1
    GDK_URL: http://gdk.test:3000
    KNAPSACK_TEST_FILE_PATTERN: "qa/specs/features/**/*_spec.rb"
    QA_SUITE_STATUS_ENV_FILE: "$CI_PROJECT_DIR/suite_status.env"
  before_script:
    - echo "SUITE_RAN=true" > "$QA_SUITE_STATUS_ENV_FILE"
    - echo -e "\e[0Ksection_start:`date +%s`:pull_image[collapsed=true]\r\e[0KPull GDK QA image"
    - docker pull ${GDK_IMAGE}
    - echo -e "\e[0Ksection_end:`date +%s`:pull_image\r\e[0K"
    # Despite `incremental: false` and `static: true`, GDK sometimes fails to start without increasing max user watches
    # This is why we're not running the GDK container as a service
    - sysctl -n -w fs.inotify.max_user_watches=524288
    - echo -e "\e[0Ksection_start:`date +%s`:launch_gdk[collapsed=true]\r\e[0KLaunch GDK"
    - mkdir -p $CI_PROJECT_DIR/log/gdk $CI_PROJECT_DIR/log/gitlab
    # This command matches the permissions of the user that runs GDK inside the container.
    - chown -R 1000:1000 $CI_PROJECT_DIR/log
    - |
      docker run -d --rm --name gdk --network host \
        --volume $CI_PROJECT_DIR/log/gdk:/home/gdk/gitlab-development-kit/log \
        --volume $CI_PROJECT_DIR/log/gitlab:/home/gdk/gitlab-development-kit/gitlab/log \
        ${GDK_IMAGE}
    # With `FF_NETWORK_PER_BUILD=1` and `--network host` the IP of the gdk container should be 172.18.0.2, but we get it
    # dynamically just in case
    - echo "$(docker exec gdk bash -c "getent hosts \$HOSTNAME" | awk '{print $1}') gdk.test" >> /etc/hosts
    - echo -e "\e[0Ksection_end:`date +%s`:launch_gdk\r\e[0K"
    - echo -e "\e[0Ksection_start:`date +%s`:install_gems[collapsed=true]\r\e[0KInstall gems"
    - source scripts/utils.sh
    - cd qa && bundle config set --local without 'development' && bundle install
    - echo -e "\e[0Ksection_end:`date +%s`:install_gems\r\e[0K"
  script:
    - echo -e "\e[0Ksection_start:`date +%s`:healthcheck[collapsed=true]\r\e[0KWait for gdk to start"
    - retry_times_sleep 100 3 test_url $GDK_URL/users/sign_in
    - echo -e "\e[0Ksection_end:`date +%s`:healthcheck\r\e[0K"
    - echo -e "\e[0Ksection_start:`date +%s`:run_tests\r\e[0KRun E2E tests"
    - export QA_COMMAND="bundle exec bin/qa ${QA_SCENARIO:=Test::Instance::All} $GDK_URL $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"
    - echo "Running - '$QA_COMMAND'"
    - eval "$QA_COMMAND"
    - echo -e "\e[0Ksection_end:`date +%s`:run_tests\r\e[0K"
  artifacts:
    paths:
      - qa/tmp
      - log/gitlab
      - log/gdk/*/current
    reports:
      junit: qa/tmp/rspec-*.xml
      dotenv: "$QA_SUITE_STATUS_ENV_FILE"
    expire_in: 7 days
    when: always

# Take the existing GDK docker image and reconfigure it with Postgres load
# balancing. Adding 5s lag to 1 of the replicas to validate robustness of
# the load balancer.
.gdk-with-load-balancer-setup:
  before_script:
    - !reference [".gdk-qa-base", "before_script"]
    - |
      docker exec gdk bash -c "
        gdk config set postgresql.replica.enabled true &&\
        gdk config set postgresql.replica_2.enabled true &&\
        gdk config set load_balancing.enabled true &&\
        gdk reconfigure &&\
        gdk restart"

# ==========================================
# Pre stage
# ==========================================
# override .download-knapsack-report job to not depend on qa-image build
download-knapsack-report:
  extends:
    - .download-knapsack-report
    - .ruby-image
    - .bundler-variables
    - .qa-cache
    - .rules:download-knapsack
  variables:
    GIT_STRATEGY: clone
  before_script:
    - cd qa && bundle install
  after_script: []

# ==========================================
# Test stage
# ==========================================
gdk-qa-smoke:
  extends:
    - .gdk-qa-base
    - .gitlab-qa-report
    - .rules:gdk:qa-smoke
  variables:
    QA_SCENARIO: Test::Instance::Smoke
    QA_RUN_TYPE: gdk-qa-smoke

gdk-qa-smoke-with-load-balancer:
  extends:
    - .gdk-qa-base
    - .gdk-with-load-balancer-setup
  variables:
    QA_SCENARIO: Test::Instance::Smoke
    QA_RUN_TYPE: gdk-qa-smoke
  artifacts:
    paths:
      - log
    reports:
      dotenv: ""
  rules:
    - !reference [".rules:test:never-schedule-pipeline", rules]
    - !reference [".rules:test:gdk-load-balancer-changes", rules]
  allow_failure: true

gdk-qa-reliable:
  extends:
    - .gdk-qa-base
    - .gitlab-qa-report
    - .parallel
    - .rules:gdk:qa-parallel
  variables:
    QA_SCENARIO: Test::Instance::Blocking
    QA_RUN_TYPE: gdk-qa-blocking
  parallel: 10

gdk-qa-reliable-selective:
  extends:
    - .gdk-qa-base
    - .gitlab-qa-report
    - .rules:gdk:qa-selective
  variables:
    QA_SCENARIO: Test::Instance::Blocking
    QA_RUN_TYPE: gdk-qa-blocking

gdk-qa-reliable-with-load-balancer:
  extends:
    - .gdk-qa-base
    - .gdk-with-load-balancer-setup
    - .parallel
  variables:
    QA_SCENARIO: Test::Instance::Blocking
    QA_RUN_TYPE: gdk-qa-blocking
  artifacts:
    paths:
      - log
    reports:
      dotenv: ""
  rules:
    - !reference [".rules:test:never-schedule-pipeline", rules]
    - !reference [".rules:test:gdk-load-balancer-changes", rules]
  allow_failure: true

gdk-qa-non-blocking:
  extends:
    - .gdk-qa-base
    - .parallel
  variables:
    QA_SCENARIO: Test::Instance::NonBlocking
    QA_RUN_TYPE: gdk-qa-non-blocking
  rules:
    - when: manual
      allow_failure: true

# ==========================================
# Post test stage
# ==========================================
e2e-test-report:
  extends: .rules:report:allure-report
  variables:
    ALLURE_REPORT_RESULTS_GLOB: "qa/tmp/allure-results"

upload-knapsack-report:
  extends:
    - .upload-knapsack-report
    - .rules:report:process-results
  variables:
    QA_KNAPSACK_REPORT_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/knapsack/*/*.json

export-test-metrics:
  extends:
    - .export-test-metrics
    - .rules:report:process-results
  variables:
    QA_METRICS_REPORT_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/test-metrics-*.json

.gitlab-qa-report:
  variables:
    QA_RSPEC_JSON_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/rspec-*.json
    QA_SYSTEM_LOG_FILE_PATTERN: $CI_PROJECT_DIR/test_output/logs

generate-test-session:
  extends:
    - .generate-test-session
    - .rules:report:process-results
  variables:
    QA_RSPEC_JSON_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/rspec-*.json

notify-slack:
  extends:
    - .notify-slack
    - .rules:report:process-results
  variables:
    QA_RSPEC_XML_FILE_PATTERN: $CI_PROJECT_DIR/qa/tmp/rspec-*.xml