e2e

command
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 5 Imported by: 0

README

How to run e2e tests locally

TLDR

Simply run:

bash local-e2e.sh

You can also run each step separately.

Install Newman

Navigate to e2e folder an install Newman. You can skip this step if you already did it before.

nvm install 8 || nvm use --delete-prefix v8.12.0
npm install newman@4.1.0
node_modules/.bin/newman --version

Launch a Postgres Database for end-to-end tests

You can use Docker to launch a container for Postgres. The database must have the following configuration:

  • DB Name: vulndbtest
  • User: vulndb
  • Password: vulndb
  • Port: 5440
docker run --name vulndbtest -d --rm -e POSTGRES_USER=vulndb -e POSTGRES_PASSWORD=vulndb -e POSTGRES_DB=vulndbtest -p 5440:5432 postgres:13.3-alpine 

Load fixtures in the testing database

In order to obtain the current migrations you will need to clone the Vulnerability DB consumer. Next, run the migrations using Flyway (you can use Docker for that). Last step, run fixtures.go (this will load the fixtures in the testing database)

git clone git@github.com:adevinta/vulnerability-db.git /tmp/vulnerability-db

# Run the migrations on the test database
docker run --net="host" --rm -v /tmp/vulnerability-db/db/sql:/flyway/sql flyway/flyway:8-alpine -user=vulndb -password=vulndb -url=jdbc:postgresql://localhost:5440/vulndbtest -baselineOnMigrate=true migrate

# Load fixtures in the test database
TestDBPort=5440 go run fixtures.go ../_resources/e2e/fixtures/

Running end-to-end tests

Before running the end-to-end tests, you need to launch the vulnerability-db-api, listenning to port :8080:

cd .. && go install ./... && cd -
vulnerability-db-api -c ../_resources/config/local-e2e.toml &

Now you can launch the unit test running the following command:

node_modules/.bin/newman run ../_resources/e2e/postman/Vulnerability_DB_API.postman_collection.json -r cli,junit --reporter-junit-export build/reports/tests/newman.xml

Clean-up

rm -rf build/
rm -rf package-lock.json 
rm -rf node_modules/
rm -rf /tmp/vulnerability-db/
docker stop vulndbtest
sudo pkill vulnerability-db-api

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL