Skip to content

Commit

Permalink
refactor: improve e2e documentation and small clean up (#683)
Browse files Browse the repository at this point in the history
* refactor(test): remove documentation to test scan abort manually since this is now covered by e2e tests

* refactor(test): remove init services from test environment

* refactor(test): rename docker compose file in documentation

* docs(test): add short e2e test readme file

* ci(test): rename test job to e2e

* docs(test): mention new e2e readme file in contributing
  • Loading branch information
paralta committed Sep 12, 2023
1 parent 32be2a7 commit 3eef08c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ jobs:
push: false
upload: true

test:
e2e:
needs: build
name: Test
name: E2E Test
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ api` to regenerate the model, client and server code.

### Testing End to End

`make e2e` can be used run all the integration tests in the repo.
`make e2e` can be used run the end-to-end tests in the repository.

For details on how to test VMClarity end to end please see the End to End
testing guide [here](docs/test_e2e.md).
For details on how to test VMClarity, please check the testing guide [here](docs/test_e2e.md) on how to perform a test on AWS and the instructions [here](e2e/README.md) on how to run and add new tests.

## Sending Pull Requests

Expand Down
1 change: 0 additions & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,6 @@ components:
type: string
location:
type: string
# TODO(paralta) Check if image needs to be a required property
image:
$ref: '#/components/schemas/ContainerImageInfo'
id:
Expand Down
87 changes: 0 additions & 87 deletions docs/testplans/abort-scan.md

This file was deleted.

41 changes: 41 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# E2E tests

VMClarity's end-to-end tests use the [Ginkgo](https://onsi.github.io/ginkgo/) test framework and the [Gomega](https://onsi.github.io/gomega/) matcher/assertion library to leverage behavior driven testing (BDD).

This test module is composed by:

* a `testenv.go` file where the test environment is configured,
* a `docker-compose.override.yml` file which will merge and override the installation compose file to run end-to-end tests,
* a `suite_test.go` file where the steps to perform the setup and cleanup of the Ginkgo test suite are defined,
* a `helper.go` file where common methods are defined,
* and test case files.

## Run test

To run all end-to-end tests, use the following command:

```
go test -v -failfast -test.v -test.paniconexit0 -timeout 2h -ginkgo.v .
```

To run a particular end-to-end test file, use:

```
go test -v -failfast -test.v -test.paniconexit0 -timeout 2h -ginkgo.v --ginkgo.focus-file <go test file> .
```

## Write a new test

To add a new test, create a new `<test_name>_test.go` file in the current directory and use the following template:

```go
var _ = ginkgo.Describe("<add a brief test case description>", func() {
ginkgo.Context("<describe conditions or inputs>", func() {
ginkgo.It("<describe the behaviour or feature being tested>", func(ctx ginkgo.SpecContext) {
<implement test code>
})
})
})
```

Additionally, check the available test cases (e.g. `basic_scan_test.go`) to get started.
16 changes: 1 addition & 15 deletions e2e/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ func (e *Environment) ServicesReady(ctx context.Context) (bool, error) {
return false, err
}

// TODO(paralta) remove when grype-server-init service is removed.
initServices := e.InitServices()
if len(services)-len(initServices) != len(ps) {
if len(services) != len(ps) {
return false, nil
}

Expand All @@ -159,18 +157,6 @@ func (e *Environment) Services() []string {
return services
}

// TODO(paralta) remove when grype-server-init service is removed.
func (e *Environment) InitServices() []string {
services := make([]string, 0, len(e.project.Services))
for _, srv := range e.project.Services {
val, ok := srv.Labels["type"]
if ok && val == "init" {
services = append(services, srv.Name)
}
}
return services
}

func (e *Environment) VMClarityURL() (*url.URL, error) {
var vmClarityBackend types.ServiceConfig
var ok bool
Expand Down
4 changes: 2 additions & 2 deletions installation/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ copied for this.

## Starting VMClarity
```
docker compose --project-name vmclarity --file dockercompose.yml up -d --wait --remove-orphans
docker compose --project-name vmclarity --file docker-compose.yml up -d --wait --remove-orphans
```

## Stopping VMClarity
```
docker compose --project-name vmclarity --file dockercompose.yml down --remove-orphans
docker compose --project-name vmclarity --file docker-compose.yml down --remove-orphans
```

0 comments on commit 3eef08c

Please sign in to comment.