# Running integration tests against neo4j db in CI/CD gitlab

**URL:** <https://community.neo4j.com/t/running-integration-tests-against-neo4j-db-in-ci-cd-gitlab/13568>\
**Category:** Javascript\
**Tags:** neo4j-driver, neo4j\
**Created:** [January 12, 2020, 6:05pm UTC](https://community.neo4j.com/t/running-integration-tests-against-neo4j-db-in-ci-cd-gitlab/13568 "2020-01-12T18:05:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maros.zeleny](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/maros.zeleny/32/3913_2.png) [@maros.zeleny](https://community.neo4j.com/u/maros.zeleny)\
**Post date:** [January 12, 2020, 6:05pm UTC](https://community.neo4j.com/t/running-integration-tests-against-neo4j-db-in-ci-cd-gitlab/13568/1 "2020-01-12T18:05:05Z")

</div>

Hi,  
I would like to ask what is right approach of running integration tests against neo4j db in CI/CD ?

Here is my case:  
We have backend implemented in node.js and using neo4j-driver for connection to db. We use gitlab for CI/CD. We are running in CI/CD the test stage with neo4j database and our neo4j backend service defined as services in docker-compose. The problem is when database is started, we seed data into it using cypher-shell but somehow our service started integration test before and test stage failed.  
We tried using sleep command or official script wait-for-it.sh ([GitHub - vishnubob/wait-for-it: Pure bash script to test and wait on the availability of a TCP host and port](https://github.com/vishnubob/wait-for-it)) to seed db before running tests but it does not work. This problem happen only in CI/CD, locally it works fine (f.e. running npm run test).

What is the right approach or what are you doing if you want to perform integration tests in CI/CD ? It's good idea ?

below you can see our docker compose file

```auto
version: "3"

services:
  database-neo4j-test:
      image: neo4j:3.5.3
      container_name: database-neo4j-test
      ports:
      - "7474:7474"
      - "7687:7687"
      volumes:
        - ../database-neo4j-service/src/scripts/init.cql:/var/lib/neo4j/import/init.cql
      environment:
        - NEO4J_AUTH=neo4j/neo4j  
        - NEO4J_dbms_connector_bolt_thread __pool__ min__size=100
        - NEO4J_dbms_connector_bolt_thread __pool__ max__size=5000
        - NEO4J_dbms_connector_bolt_thread __pool__ keep__alive=5m
        - NEO4J_dbms_threads_worker__count=1000
        - NEO4J_dbms_memory_heap_max__size=5G
        - NEO4J_dbms_memory_heap_initial__size=1G
        - NEO4J_dbms_memory_heap_max__size=2G
        - NEO4J_dbms_memory_heap_initial__size=2G
        - NEO4J_relationship __auto__ indexing=true
        - NEO4J_relationship __keys__ indexable=arch_id
        - NEO4J_relationship __keys__ indexable=type
      command: >
            sh -c "bin/neo4j-admin set-initial-password neo4j || true &&
            bin/neo4j start &&
            sleep 20 &&
            cat /var/lib/neo4j/import/init.cql | NEO4J_USERNAME=neo4j NEO4J_PASSWORD=neo4j cypher-shell --fail-fast > init_output.log 2>&1 &&
            tail -f /dev/null"
            
  neo4j-service-test:
    container_name: neo4j-service-test
    build:
      context: .
      dockerfile: Dockerfile.gitlab.test
      args:
        - NPM_CONFIG=${NPM_CONFIG}
    command: sh -c "./scripts/wait-for-it.sh database-neo4j-test:7687; npm run test:gitlab"
    environment:
      NEO4J_URL: bolt://archmesh-neo4j-test:7687
    depends_on:
      - database-neo4j-test

```

---

<div class="post-metadata">

**Author:** ![krisgeus](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/krisgeus/32/6166_2.png) [@krisgeus](https://community.neo4j.com/u/krisgeus)\
**Post date:** [January 13, 2020, 1:07am UTC](https://community.neo4j.com/t/running-integration-tests-against-neo4j-db-in-ci-cd-gitlab/13568/2 "2020-01-13T01:07:17Z")

</div>

I think the problem is that you start both processes as a service. For seeding the database that’s fine but the test should be run as a task or step in your gitlab pipeline.  
I think gitlab will make sure the build step will start after the service is ready
