Skip to content

Commit

Permalink
feat: use zendro-env to setup integration tests environment (#158)
Browse files Browse the repository at this point in the history
* feat: add integration-tests env cli

* fix: missing experiment data model with wrong extension

* fix: remove unused templates from the env config file

* refactor: move all integration-test related files to integration_test_misc

* feat: update .testenv.json
- service url for service connection checks
- mocha test definitions

* fix: duplicated bak patches

* fix: move unused patches to patches folder

* refactor: place service name at the top

* fix: update testenv paths

* refactor: restore old test-* scripts format

* fix: gitignore integration_test_env folder

* feat: add env property to the testenv config

* fix: remove unnecessary npm install from ncbi_sim_srv

* feat: assign names to postgres containers

* docs: update integration-tests documentation

* refactor: move env entry in config file to the top
  • Loading branch information
davelsan authored Oct 8, 2020
1 parent a88416a commit 0904bc8
Show file tree
Hide file tree
Showing 64 changed files with 554 additions and 1,062 deletions.
16 changes: 1 addition & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@
# NPM package manager temporary files and folders
node_modules
npm-debug.log
package-lock.json

# ModelGen output folders
migrations
generic
sql
distributed
adapters
zendro-server
resolvers
schemas
validations
patches
adapters
seeders
TestConcept.js
.eslintrc.js
test/integration_test_env
79 changes: 79 additions & 0 deletions .testenv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"cwd": "./test/integration_test_env",
"env": {
"NODE_JQ_SKIP_INSTALL_BINARY": true
},
"docker": "../integration_test_misc/docker-compose-test.yml",
"services": [
{
"name": "gql_science_db_graphql_server1",
"template": "gql",
"codegen": "gql-codegen",
"url": "http://localhost:3000/graphql"
},
{
"name": "gql_science_db_graphql_server2",
"template": "gql",
"codegen": "gql-codegen",
"url": "http://localhost:3030/graphql"
}
],
"models": [
{
"opts": [ "--migrations" ],
"path": "../integration_test_misc/integration_test_models_instance1",
"target": [ "gql_science_db_graphql_server1" ]
},
{
"opts": [ "--migrations" ],
"path": "../integration_test_misc/integration_test_models_instance2",
"target": [ "gql_science_db_graphql_server2" ]
}
],
"patches": [
{
"opts": [ "-V", "never" ],
"src": "../integration_test_misc/patches/model_aminoacidsequence.patch",
"dest": "gql_science_db_graphql_server1/models/generic/aminoacidsequence.js"
},
{
"opts": [ "-V", "never" ],
"src": "../integration_test_misc/patches/individual_validate.patch",
"dest": "gql_science_db_graphql_server1/validations/individual.js"
},
{
"opts": [ "-V", "never" ],
"src": "../integration_test_misc/patches/accession_validate_instance1.patch",
"dest": "gql_science_db_graphql_server1/validations/accession.js"
},
{
"opts": [ "-V", "never" ],
"src": "../integration_test_misc/patches/cat_readAllCursor.patch",
"dest": "gql_science_db_graphql_server1/models/sql/cat.js"
}
],
"templates": [
{
"name": "gql",
"branch": "master",
"url": "https://github.com/Zendro-dev/graphql-server.git"
},
{
"name": "gql-codegen",
"url": "../../.git",
"source": true
}
],
"tests": [
{
"name": "integration",
"runner": "mocha",
"target": "gql-codegen/test/mocha_integration_test.js"
},
{
"name": "unit",
"runner": "mocha",
"target": "gql-codegen/test/mocha_unit_test.js"
}
]
}
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,41 @@ Command line utility to generate the structure files that Zendro [graphql-server

## Set up
Clone the repository and run:
```
```sh
$ npm install -g
```
If you only want to install it locally run `npm install` instead

## Usage

To run the unit-test case:
```
```sh
$ npm run test-unit
```

To run the integration-test case
```
```sh
$ npm run test-integration [-- OPTIONS]
```
Note:
Integration-test case creates a docker-compose environment with three servers:
Integration-test case creates a `docker-compose` environment with three servers:

```
```sh
gql_postgres
gql_science_db_graphql_server
gql_ncbi_sim_srv
```

### Examples of use - Test integration
### Examples of use - Integration Tests

To see full test-integration info:
```bash
$ npm run test-integration -- -h
```
This repository uses [`zendro-env`](https://github.com/Zendro-dev/zendro-integration-tests) to create the integration-tests environment and launch the `mocha` test-runner. Find more information in its repository documentation.

#### Default
To execute a default test run:
```bash
$ npm run test-integration
```

To test a specific `graphql-server` branch:
```bash
$ npm run test-integration -- b <branch_name>
```

To generate code:
```bash
$ npm run test-integration -- -g
```

To generate code and do the tests, removing all Docker images at end:
```bash
$ npm run test-integration -- -T
Expand All @@ -66,19 +54,27 @@ To do the tests only and keep the containers running at end:
$ npm run test-integration -- -t -k
```

To restart containers:
#### Environment Commands

To get information about available commands and options:
```bash
$ npm run test-env -- --help
```

To manage docker containers:
```bash
$ npm run test-integration -- -r
$ npm run test-env -- docker # up containers and check connections
$ npm run test-env -- docker --down # down containers
```

To clean generated code, remove containers and volumes:
```bash
$ npm run test-integration -- -C
$ npm run test-env -- -C
```

To do a full clean up (removes containers, images and code):
```bash
$ npm run test-integration -- -c
$ npm run test-env -- -c
```

### Examples of use - Code Generator
Expand Down
15 changes: 0 additions & 15 deletions docker/Dockerfile.ncbi_sim_srv

This file was deleted.

Empty file removed docker/error_server.log
Empty file.
4 changes: 0 additions & 4 deletions docker/integration_test_run/.gitignore

This file was deleted.

35 changes: 0 additions & 35 deletions docker/integration_test_run/scripts/checkout-branch.sh

This file was deleted.

41 changes: 0 additions & 41 deletions docker/integration_test_run/scripts/clean-workspace.sh

This file was deleted.

Loading

0 comments on commit 0904bc8

Please sign in to comment.