Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup integration tests for the Web API #104

Closed
dcastro opened this issue May 11, 2022 · 0 comments · Fixed by #109
Closed

Setup integration tests for the Web API #104

dcastro opened this issue May 11, 2022 · 0 comments · Fixed by #109
Assignees
Labels
web-api This issue is related to the Coffer Web API

Comments

@dcastro
Copy link
Member

dcastro commented May 11, 2022

Clarification and motivation

We have a few tests for the Web API written in mocha.

The main reason why they were written in javascript in the first place was so that they would serve as documentation for whoever writes the frontend. However:

  1. This makes maintaining them (a bit) harder.
  2. Enabling the tests in the pipeline will also be a bit more troublesome.
  3. The frontend will (probably) be written in Purescript, so it's not like having the api's tests in javascript helps that much.

I think we could still achieve our goal (documenting the web API) if we re-write the tests in Haskell, without using a servant client and without relying on coffer's data types/encoders/decoders. We could just write json literals in the tests (e.g. with aesonQQ), manually add the headers, etc.

These tests should:

  • Be written in a new test suite, coffer:test:server-integration
  • Spin up a couple of vault instances in Main before running the tests (just like scripts/run-bats-tests.sh).
  • Be independent of each other. For example, in the golden tests for the CLI (written in bats), we delete all entries in between tests.
  • Not step on each other's toes. E.g. we don't want two tests writing to/reading from the same vault instance at the same time, or we'll have race conditions everywhere. We basically have two options: (1) run the tests sequentially, or (2) spin up a new vault instance for each individual test. Let's keep it simple for now and just run the tests sequentially. We enforce this by setting the NumThreads option to 1 (and using localOption in Main).

Let's:

  • setup the test suite
  • create a makefile target for running the tests
  • enable the tests in the pipeline
  • write 1 or 2 tests just to prove that the setup works

We'll write the remaining tests in a separate issue

Acceptance criteria

  • We have a new test suite with a couple of tests
  • We have a makefile target for devs to easily run the tests
  • The pipeline is running the tests and passing
@dcastro dcastro added the web-api This issue is related to the Coffer Web API label May 11, 2022
@DK318 DK318 self-assigned this May 13, 2022
DK318 added a commit that referenced this issue May 16, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: created two scripts:
1. Spins up two vault instances and writes their pids in file.
2. Reads pids from file, deletes it and kills vault instances.
Also added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: created two scripts:
1. Spins up two vault instances and writes their pids in file.
2. Reads pids from file, deletes it and kills vault instances.
Also added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: created two scripts:
1. Spins up two vault instances and writes their pids in file.
2. Reads pids from file, deletes it and kills vault instances.
Also added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: created two scripts:
1. Spins up two vault instances and writes their pids in file.
2. Reads pids from file, deletes it and kills vault instances.
Also added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 16, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 17, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 17, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 17, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 24, 2022
Problem: we don't have Web API integration tests in our pipeline.
We should create them and add them to the pipeline.

Solution: created `server-integration` test suite with two
unit tests.
DK318 added a commit that referenced this issue May 24, 2022
Problem: we have some integration tests for Web API, but don't have
makefile target to run them.

Solution: added `server-integration` makefile target to run server integration tests.
DK318 added a commit that referenced this issue May 24, 2022
Problem: we have some server integration tests but we don't run them
in pipeline.

Solution: add `server integration` task in pipeline.
DK318 added a commit that referenced this issue May 24, 2022
…tests-pipeline

[#104] Web API integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-api This issue is related to the Coffer Web API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants