title: Gitlab continuous integration testing with Selenium
body: <p>I am working on a project to build, test and deploy an application to the cloud using a <strong>.gitlab-ci.yml</strong></p>
  
  <p><strong>1) Build the backend and frontend using pip install and npm install</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>2) Run unit and functional tests using PyUnit and Python Selenium</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>3) Deploy to Google Cloud using the sdk</strong></p>
  
  <pre><code>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 &gt; /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
  </code></pre>
  
  <p>This all runs perfectly, except for the selenium tests are run on the deployed url not the current build:</p>
  
  <pre><code>python tests/example.py http://selenium__standalone-chrome:4444/wd/hub https://$CI_BUILD_REF_SLUG-dot-$GAE_PROJECT.appspot.com
  </code></pre>
  
  <p>I need to have gitlab run three things simultaneously:
   a) Selenium
   b) Python server with the application
   - Test script</p>
  
  <p>Possible approaches to run the python server:</p>
  
  <ul>
  <li>Run within the same terminal commands as the test script somehow</li>
  <li>Docker in Docker</li>
  <li>Service</li>
  </ul>
  
  <p>Any advice, or answers would be greatly appreciated!</p>