.gitlab-ci.yml 18.4 KB
Newer Older
1 2 3
variables:
  DOCKER_TLS_CERTDIR: ""
  GIT_STRATEGY: clone
4
  REGISTRY_USER: chembl/chembl
5
  SERVER_APPLICATION: delayed-jobs/delayed-jobs-api/delayed-jobs-server
6
  SERVER_IMAGE_TAG: ${CI_REGISTRY}/${REGISTRY_USER}/${SERVER_APPLICATION}:${CI_COMMIT_SHORT_SHA}
7
  DOCKER_DRIVER: overlay
David Mendez's avatar
David Mendez committed
8
  CONFIGS_FOLDER: run_config
9 10
  # Config unit tests
  CONFIG_UNIT_TESTS_FILE_PATH: ${CONFIGS_FOLDER}/unit_tests.yml
11
  # Config staging
David Mendez's avatar
David Mendez committed
12
  CONFIG_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging.yml
13
  CONFIG_GUNICORN_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging.gunicorn.config.py
14
  INGRESS_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/ingress-staging.yml
15
  AUTOSCALER_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-staging.yml
16
  # Config prod_hx
17
  CONFIG_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx.yml
18
  CONFIG_GUNICORN_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx.gunicorn.config.py
19
  INGRESS_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/ingress-prod_hx.yml
20
  AUTOSCALER_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-prod_hx.yml
21
  # Config prod_hh
David Mendez's avatar
David Mendez committed
22 23
  CONFIG_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh.yml
  CONFIG_GUNICORN_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh.gunicorn.config.py
24
  INGRESS_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/ingress-prod_hh.yml
25
  AUTOSCALER_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/autoscaler-prod_hh.yml
26

David Mendez's avatar
David Mendez committed
27
stages:
28
  - build
29
  - prepare_config_tests
30
  - test_and_qa
David Mendez's avatar
David Mendez committed
31
  - prepare_config_staging
32
  - deploy_to_staging
David Mendez's avatar
David Mendez committed
33
  - test_staging
34 35 36
  - prepare_config_hx_hh
  - deploy_to_prod_hx_hh
  - test_prod_hx_hh
37
  - functional_tests_prod_public
38
  - schedules
David Mendez's avatar
David Mendez committed
39

40
# ----------------------------------------------------------------------------------------------------------------------
41
# build
42
# ----------------------------------------------------------------------------------------------------------------------
David Mendez's avatar
David Mendez committed
43 44
build_docker_image_server:
  image:
David Mendez's avatar
David Mendez committed
45
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker/compose:1.24.1
David Mendez's avatar
David Mendez committed
46 47 48 49
    entrypoint: ["/bin/sh", "-c"]
  stage: build
  variables:
    DOCKER_HOST: tcp://docker:2375
50 51
  except:
    - schedules
52 53 54 55
  services:
    - docker:dind
  tags:
    - dind
David Mendez's avatar
David Mendez committed
56 57
  before_script:
    - apk add curl jq
David Mendez's avatar
David Mendez committed
58
    - echo $DOCKERHUB_REGISTRY_PASSWORD | docker login -u $DOCKERHUB_REGISTRY_USER --password-stdin $DOCKERHUB_REGISTRY
David Mendez's avatar
David Mendez committed
59
    - |
David Mendez's avatar
David Mendez committed
60
      TOKEN=$(curl --user "${DOCKERHUB_REGISTRY_USER}:${$DOCKERHUB_REGISTRY_PASSWORD}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token) && curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1
David Mendez's avatar
David Mendez committed
61 62 63
  script:
    - set -x
    # Check rate limit
David Mendez's avatar
David Mendez committed
64
    - docker version # verify docker cli is there. Also prints server info
David Mendez's avatar
David Mendez committed
65
    - echo ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}
David Mendez's avatar
David Mendez committed
66
#    - echo ${CI_DEPENDENCY_PROXY_PASSWORD} | docker login -u ${CI_DEPENDENCY_PROXY_USER} --password-stdin ${CI_DEPENDENCY_PROXY_SERVER}
David Mendez's avatar
David Mendez committed
67 68 69 70
    - echo building $SERVER_IMAGE_TAG
    - docker-compose build delayed-jobs-server-prod
    - echo Deploying $SERVER_IMAGE_TAG
    - docker push $SERVER_IMAGE_TAG
71

72 73 74
# ----------------------------------------------------------------------------------------------------------------------
# QA
# ----------------------------------------------------------------------------------------------------------------------
75
pylint:
76
  stage: test_and_qa
77
  image:
78
    name: $SERVER_IMAGE_TAG
79
    entrypoint: [""]
80 81
  except:
    - schedules
82
  script:
83
  - pwd
84
  - ls
85
  - echo 'disabled temporarily'
86

David Mendez's avatar
David Mendez committed
87 88 89
# ----------------------------------------------------------------------------------------------------------------------
# Tests
# ----------------------------------------------------------------------------------------------------------------------
90 91 92
prepare_config_tests:
  stage: prepare_config_tests
  image:
93
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine/git
94 95 96 97 98
    entrypoint: ["/bin/sh", "-c"]
  except:
    - schedules
  script:
    - set -x
99
    - rm -rf ${CONFIGS_FOLDER} || true
100 101 102 103 104 105
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_UNIT_TESTS_FILE_PATH}

106
unit_tests:
107
  stage: test_and_qa
108
  image:
109
    name: $SERVER_IMAGE_TAG
110
    entrypoint: [""]
111 112
  except:
    - schedules
113
  script:
David Mendez's avatar
David Mendez committed
114
  - env
115
  - CONFIG_FILE_PATH=${CONFIG_UNIT_TESTS_FILE_PATH} python -m unittest
116

David Mendez's avatar
David Mendez committed
117 118 119
# ----------------------------------------------------------------------------------------------------------------------
# Deployment to staging
# ----------------------------------------------------------------------------------------------------------------------
David Mendez's avatar
David Mendez committed
120
prepare_config_staging:
David Mendez's avatar
David Mendez committed
121
  stage: prepare_config_staging
David Mendez's avatar
David Mendez committed
122
  image:
123
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine/git
David Mendez's avatar
David Mendez committed
124
    entrypoint: ["/bin/sh", "-c"]
125 126
  only:
    - staging
127 128
  except:
    - schedules
David Mendez's avatar
David Mendez committed
129
  script:
130
    - set -x
131
    - rm -rf ${CONFIGS_FOLDER} || true
David Mendez's avatar
David Mendez committed
132
    - mkdir -p ${CONFIGS_FOLDER}
David Mendez's avatar
David Mendez committed
133
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
David Mendez's avatar
David Mendez committed
134 135
  artifacts:
    paths:
David Mendez's avatar
David Mendez committed
136
      - ${CONFIG_STAGING_FILE_PATH}
137
      - ${CONFIG_GUNICORN_STAGING_FILE_PATH}
138
      - ${INGRESS_STAGING_FILE_PATH}
139
      - ${AUTOSCALER_STAGING_FILE_PATH}
David Mendez's avatar
David Mendez committed
140

141
deploy_to_staging:
142
  stage: deploy_to_staging
143
  image:
144
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/lachlanevenson/k8s-kubectl:latest
145
    entrypoint: ["/bin/sh", "-c"]
146
  only:
147
    - staging
148 149
  except:
    - schedules
150 151
  environment:
    name: staging
152
    url: ${SERVER_URL_STAGING}
153 154
  script:
  - set -x
155 156 157
  - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
  - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
  - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
David Mendez's avatar
David Mendez committed
158 159 160 161
  - kubectl config set-context ${CHEMBL_NS_STAGING} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
  - kubectl config use-context ${CHEMBL_NS_STAGING}
  - echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
  - kubectl get pods -n ${CHEMBL_NS_STAGING}
162 163 164
  - kubectl create secret generic ${ID_RSA_SECRET_NAME_STAGING} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HX} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
  - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_STAGING} --from-file=RUN_CONFIG.yml=${CONFIG_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
  - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_STAGING} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run | kubectl replace -f -
David Mendez's avatar
David Mendez committed
165
  - cat ${CONFIG_STAGING_FILE_PATH}
166
  - cat ${CONFIG_GUNICORN_STAGING_FILE_PATH}
David Mendez's avatar
David Mendez committed
167
  - sed -i "s~<NAMESPACE>~${CHEMBL_NS_STAGING}~" k8s-deployment.yaml
168
  - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_STAGING}~" k8s-deployment.yaml
169 170
  - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_STAGING}~" k8s-deployment.yaml
  - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_STAGING}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
171 172
  - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
  - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
173
  - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
174
  - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_STAGING}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
175
  - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HX}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
176
  - sed -i "s~<NFS_PATH>~${NFS_PATH_HX}~" k8s-deployment.yaml
177
  - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_STAGING}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
178
  - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
179
  - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_STAGING}~" k8s-deployment.yaml
180
  - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_STAGING}~" k8s-deployment.yaml
181
  - cat k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
182
  - kubectl apply -n ${CHEMBL_NS_STAGING} -f k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
183
  - kubectl get pods -n ${CHEMBL_NS_STAGING}
184 185 186
  - cat ${INGRESS_STAGING_FILE_PATH}
  - kubectl apply -n ${CHEMBL_NS_STAGING} -f ${INGRESS_STAGING_FILE_PATH}
  - kubectl describe ingress -n ${CHEMBL_NS_STAGING}
187 188
  - cat ${AUTOSCALER_STAGING_FILE_PATH}
  - kubectl apply -n ${CHEMBL_NS_STAGING} -f ${AUTOSCALER_STAGING_FILE_PATH}
189 190 191 192

# ----------------------------------------------------------------------------------------------------------------------
# Test staging
# ----------------------------------------------------------------------------------------------------------------------
193
functional_tests_staging:
David Mendez's avatar
David Mendez committed
194
  stage: test_staging
David Mendez's avatar
David Mendez committed
195 196 197 198 199 200 201 202 203 204
  image:
    name: $SERVER_IMAGE_TAG
    entrypoint: [""]
  only:
  - staging
  environment:
    name: staging
  script:
  - set -x
  - sleep 30 # Give some time for the deployment to take effect.
David Mendez's avatar
David Mendez committed
205
  - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
206 207 208 209

# ----------------------------------------------------------------------------------------------------------------------
# Deployment to prod hx
# ----------------------------------------------------------------------------------------------------------------------
210
prepare_config_prod_hx:
David Mendez's avatar
David Mendez committed
211
  stage: prepare_config_hx_hh
212
  image:
213
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine/git
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
    entrypoint: ["/bin/sh", "-c"]
  only:
    - master
  except:
    - schedules
  script:
    - rm -rf ${CONFIGS_FOLDER} || true
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_PROD_HX_FILE_PATH}
      - ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
      - ${INGRESS_PROD_HX_FILE_PATH}
      - ${AUTOSCALER_PROD_HX_FILE_PATH}

deploy_to_prod_hx:
David Mendez's avatar
David Mendez committed
231
  stage: deploy_to_prod_hx_hh
232
  image:
233
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/lachlanevenson/k8s-kubectl:latest
234 235 236 237 238 239 240 241 242 243 244 245 246 247
    entrypoint: ["/bin/sh", "-c"]
  only:
    - master
  except:
    - schedules
  script:
    - set -x
    - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
    - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
    - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
    - kubectl config set-context ${CHEMBL_NS_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
    - kubectl config use-context ${CHEMBL_NS_PROD}
    - echo ${CHEMBL_NS_PROD} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
    - kubectl get pods -n ${CHEMBL_NS_PROD}
248 249 250
    - kubectl create secret generic ${ID_RSA_SECRET_NAME_PROD_HX} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HX} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HX} --from-file=RUN_CONFIG.yml=${CONFIG_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_PROD_HX} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
    - cat ${CONFIG_PROD_HX_FILE_PATH}
    - cat ${CONFIG_GUNICORN_PROD_HX_FILE_PATH}
    - sed -i "s~<NAMESPACE>~${CHEMBL_NS_PROD}~" k8s-deployment.yaml
    - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
    - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
    - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
    - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HX}~" k8s-deployment.yaml
    - sed -i "s~<NFS_PATH>~${NFS_PATH_HX}~" k8s-deployment.yaml
    - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
    - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_PROD_HX}~" k8s-deployment.yaml
266
    - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_PROD_HX}~" k8s-deployment.yaml
267 268 269 270 271 272 273 274 275 276
    - cat k8s-deployment.yaml
    - kubectl apply -n ${CHEMBL_NS_PROD} -f k8s-deployment.yaml
    - kubectl get pods -n ${CHEMBL_NS_PROD}
    - cat ${INGRESS_PROD_HX_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${INGRESS_PROD_HX_FILE_PATH}
    - kubectl describe ingress -n ${CHEMBL_NS_PROD}
    - cat ${AUTOSCALER_PROD_HX_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${AUTOSCALER_PROD_HX_FILE_PATH}

functional_tests_prod_hx:
David Mendez's avatar
David Mendez committed
277
  stage: test_prod_hx_hh
278 279 280 281 282 283 284 285
  image:
    name: $SERVER_IMAGE_TAG
    entrypoint: [""]
  only:
  - master
  script:
  - set -x
  - sleep 30 # Give some time for the deployment to take effect.
286
  - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_HX} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HX}
287

David Mendez's avatar
David Mendez committed
288 289 290 291
# ----------------------------------------------------------------------------------------------------------------------
# Deployment to prod hh
# ----------------------------------------------------------------------------------------------------------------------
prepare_config_prod_hh:
292
  stage: prepare_config_hx_hh
David Mendez's avatar
David Mendez committed
293
  image:
294
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine/git
David Mendez's avatar
David Mendez committed
295 296 297
    entrypoint: ["/bin/sh", "-c"]
  only:
    - master
298 299
  except:
    - schedules
David Mendez's avatar
David Mendez committed
300 301 302 303 304 305 306 307
  script:
    - rm -rf ${CONFIGS_FOLDER} || true
    - mkdir -p ${CONFIGS_FOLDER}
    - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
  artifacts:
    paths:
      - ${CONFIG_PROD_HH_FILE_PATH}
      - ${CONFIG_GUNICORN_PROD_HH_FILE_PATH}
308
      - ${INGRESS_PROD_HH_FILE_PATH}
309
      - ${AUTOSCALER_PROD_HH_FILE_PATH}
David Mendez's avatar
David Mendez committed
310 311

deploy_to_prod_hh:
312
  stage: deploy_to_prod_hx_hh
David Mendez's avatar
David Mendez committed
313
  image:
314
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/lachlanevenson/k8s-kubectl:latest
David Mendez's avatar
David Mendez committed
315 316 317
    entrypoint: ["/bin/sh", "-c"]
  only:
    - master
318 319
  except:
    - schedules
David Mendez's avatar
David Mendez committed
320 321 322 323 324 325 326 327 328
  script:
    - set -x
    - echo "$KUBE_CA_PEM_HH" > "$(pwd)/kube.ca.pem"
    - kubectl config set-cluster ${KUBE_CLUS_NAME_HH} --server="${KUBE_URL_HH}" --certificate-authority="$(pwd)/kube.ca.pem"
    - kubectl config set-credentials ${KUBE_USER_HH} --token="${KUBE_TOKEN_HH}"
    - kubectl config set-context ${CHEMBL_NS_PROD} --cluster=${KUBE_CLUS_NAME_HH} --user=${KUBE_USER_HH}
    - kubectl config use-context ${CHEMBL_NS_PROD}
    - echo ${CHEMBL_NS_PROD} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HH} ${KUBE_USER_HH}
    - kubectl get pods -n ${CHEMBL_NS_PROD}
329 330 331
    - kubectl create secret generic ${ID_RSA_SECRET_NAME_PROD_HH} --from-file=ID_RSA_LSF=${ID_RSA_LSF_HH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HH} --from-file=RUN_CONFIG.yml=${CONFIG_PROD_HH_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
    - kubectl create secret generic ${GUNICORN_CONFIG_SECRET_NAME_PROD_HH} --from-file=GUNICORN_CONFIG.py=${CONFIG_GUNICORN_PROD_HH_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run | kubectl replace -f -
David Mendez's avatar
David Mendez committed
332 333 334 335
    - cat ${CONFIG_PROD_HH_FILE_PATH}
    - cat ${CONFIG_GUNICORN_PROD_HH_FILE_PATH}
    - sed -i "s~<NAMESPACE>~${CHEMBL_NS_PROD}~" k8s-deployment.yaml
    - sed -i "s~<NUM_REPLICAS>~${NUM_REPLICAS_PROD_HH}~" k8s-deployment.yaml
336 337
    - sed -i "s~<CPU_LIMIT>~${CPU_LIMIT_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<CPU_REQUESTED>~${CPU_REQUESTED_PROD_HH}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
338 339 340 341 342 343 344 345 346
    - sed -i "s~<UID>~${CBL_ADM_UID}~" k8s-deployment.yaml
    - sed -i "s~<GID>~${CBL_PUB_GID}~" k8s-deployment.yaml
    - sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yaml
    - sed -i "s~<NFS_MOUNT_PATH>~${NFS_MOUNT_PATH_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<NFS_FQDN>~${NFS_FQDN_HH}~" k8s-deployment.yaml
    - sed -i "s~<NFS_PATH>~${NFS_PATH_HH}~" k8s-deployment.yaml
    - sed -i "s~<ID_RSA_SECRET_NAME>~${ID_RSA_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<RUN_CONFIG_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
    - sed -i "s~<GUNICORN_CONFIG_SECRET_NAME>~${GUNICORN_CONFIG_SECRET_NAME_PROD_HH}~" k8s-deployment.yaml
347
    - sed -i "s~<NODE_PORT>~${DELAYED_JOBS_SERVICE_PORT_PROD_HH}~" k8s-deployment.yaml
David Mendez's avatar
David Mendez committed
348 349
    - cat k8s-deployment.yaml
    - kubectl apply -n ${CHEMBL_NS_PROD} -f k8s-deployment.yaml
350
    - kubectl get pods -n ${CHEMBL_NS_PROD}
351 352 353
    - cat ${INGRESS_PROD_HH_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${INGRESS_PROD_HH_FILE_PATH}
    - kubectl describe ingress -n ${CHEMBL_NS_PROD}
354 355
    - cat ${AUTOSCALER_PROD_HH_FILE_PATH}
    - kubectl apply -n ${CHEMBL_NS_PROD} -f ${AUTOSCALER_PROD_HH_FILE_PATH}
356 357

functional_tests_prod_hh:
358
  stage: test_prod_hx_hh
359 360 361 362 363 364 365 366
  image:
    name: $SERVER_IMAGE_TAG
    entrypoint: [""]
  only:
  - master
  script:
  - set -x
  - sleep 30 # Give some time for the deployment to take effect.
367
  - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_HH} ${DJ_SERVER_ADMIN_USERNAME_PROD_HH} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HH}
368 369 370 371 372

# ----------------------------------------------------------------------------------------------------------------------
# Test prod public url
# ----------------------------------------------------------------------------------------------------------------------
functional_tests_prod_public:
David Mendez's avatar
David Mendez committed
373
  stage: functional_tests_prod_public
374 375 376 377
  image:
    name: $SERVER_IMAGE_TAG
    entrypoint: [""]
  only:
378
    - master
379
  needs: ["functional_tests_prod_hh", "functional_tests_prod_hx"]
380
  script:
381 382
    - set -x
    - sleep 30 # Give some time for the deployment to take effect.
383
    - functional_tests/run_functional_tests.py ${DELAYED_JOBS_URL_PROD_PUBLIC} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_PUBLIC}
384 385 386 387

# ----------------------------------------------------------------------------------------------------------------------
# Schedules
# ----------------------------------------------------------------------------------------------------------------------
388
delete_expired_jobs:
389
  stage: schedules
390
  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.7
391 392 393 394
  only:
    - schedules
  script:
    - set -x
395
    - pip install requests
David Mendez's avatar
David Mendez committed
396
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_STAGING} ${DJ_SERVER_ADMIN_USERNAME_STAGING} ${DJ_SERVER_ADMIN_PASSWORD_STAGING}
397 398
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_PROD_HX} ${DJ_SERVER_ADMIN_USERNAME_PROD_HX} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HX}
    - admin_tasks/delete_expired_jobs.py ${DELAYED_JOBS_URL_PROD_HH} ${DJ_SERVER_ADMIN_USERNAME_PROD_HH} ${DJ_SERVER_ADMIN_PASSWORD_PROD_HH}