Testing Gitlab Continuous Integration with Selenium

I am working on a project to build, test and deploy an application in the cloud using .gitlab-ci.yml

1) Build backend and frontend with pip install and npm install

build_backend:
  image: python
  stage: build
  script:
  - pip install requirements.txt
  artifacts:
    paths:
      - backend/

build_frontend:
  image: node
  stage: build
  script:
  - npm install
  - npm run build
  artifacts:
    paths:
      - frontend

      

2) Running unit and functional tests using PyUnit and Python Selenium

test_unit:
  image: python
  stage: test
  script:
    - python -m unittest discover

test_functional:
  image: python
  stage: test
  services:
    - selenium/standalone-chrome
  script:
    - python tests/example.py http://selenium__standalone-chrome:4444/wd/hub https://$CI_BUILD_REF_SLUG-dot-$GAE_PROJECT.appspot.com

      

3) Deploy to Google Cloud using sdk

deploy:
  image: google/cloud-sdk
  stage: deploy
  environment:
    name: $CI_BUILD_REF_NAME
    url: https://$CI_BUILD_REF_SLUG-dot-$GAE_PROJECT.appspot.com
  script:
    - echo $GAE_KEY > /tmp/gae_key.json
    - gcloud config set project $GAE_PROJECT
    - gcloud auth activate-service-account --key-file /tmp/gae_key.json
    - gcloud --quiet app deploy --version $CI_BUILD_REF_SLUG --no-promote
  after_script:
    - rm /tmp/gae_key.json

      

This all works fine, except the selenium tests are run on the expanded url and not on the current build:

python tests/example.py http://selenium__standalone-chrome:4444/wd/hub https://$CI_BUILD_REF_SLUG-dot-$GAE_PROJECT.appspot.com

      

I need gitlab to run three things at the same time: a) Selenium b) Python server with application - Test script

Possible approaches to starting a python server:

  • Execute in the same terminal commands as the test script somehow
  • Docker in Docker
  • Service

Any advice or answers would be greatly appreciated!

+3
gitlab continuous-integration selenium gitlab-ci gitlab-ci-runner


source to share


No one has answered this question yet

Check out similar questions:

63
How can I transfer artifacts to another stage?
12
post build test will work in new environment on gitlab-ci
7
How to use gitlab-ci to manage testing / building interdependent wheels
1
Gitlab CI how to deploy the latter to a specific directory
1
deploy after gitlab runner finishes
1
Image of Gitlab Runner with GCP credentials
0
Need advice with gitLab-runner for persistent deployment
0
Creating a python script to test selenium
0
How to set up gitlab ci with raw files?
0
gitlabci / e2e integration



All Articles
Loading...
X
Show
Funny
Dev
Pics