Invoke tests through ctest (#230)

Currently we define how tests should be executed in two places:
CMakeLists.txt and the CI related files.
With this commit the CI will invoke tests by calling ctest,
thus making it necessary to add and define testcases in cmake first.
As all tests starting with "integration-" or "unit-" are run,
new tests don't have to added to the CI, unless you want to define
a new category of test.
Also remove the etcd store test workflow as it's part of
test-integration now.

Co-authored-by: Fabian Kammel <fk@edgelss.systems>
This commit is contained in:
Otto Bittner 2022-06-30 13:26:21 +02:00 committed by GitHub
parent 5d293e355d
commit 6949678ead
4 changed files with 29 additions and 24 deletions

View File

@ -17,6 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GOPRIVATE: github.com/edgelesssys/* GOPRIVATE: github.com/edgelesssys/*
CTEST_OUTPUT_ON_FAILURE: True
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup Go environment - name: Setup Go environment
@ -25,22 +26,14 @@ jobs:
go-version: "1.18" go-version: "1.18"
- name: Install Dependencies - name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libcryptsetup12 libcryptsetup-dev run: sudo apt-get update && sudo apt-get install -y pkg-config libcryptsetup12 libcryptsetup-dev cmake
- name: Integration Test Coordinator - name: Create and populate build folder
run: go test -v -tags integration ./test/ run: mkdir build && cd build && cmake ..
- name: Integration Test mount # Runs all test targets starting with "integration-"
run: | - name: Integration Tests
go test -tags integration -c ./test/ run: ctest -R integration-
sudo ./test.test -test.v -v 9
working-directory: mount
- name: Integration Test disk-mapper
run: |
go test -tags integration -c ./test/
sudo ./test.test -test.v
working-directory: state
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
if: failure() if: failure()

View File

@ -17,6 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GOPRIVATE: github.com/edgelesssys/* GOPRIVATE: github.com/edgelesssys/*
CTEST_OUTPUT_ON_FAILURE: True
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -26,11 +27,12 @@ jobs:
go-version: 1.18 go-version: 1.18
- name: Install Dependencies - name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libcryptsetup12 libcryptsetup-dev libvirt-dev run: sudo apt-get update && sudo apt-get install -y pkg-config libcryptsetup12 libcryptsetup-dev cmake libvirt-dev
- name: Test main module - name: Create and populate build folder
run: go test -race -count=3 ./... run: mkdir build && cd build && cmake ..
- name: Test hack module # Runs all test targets starting with "unit-"
run: go test -race -count=3 ./... - name: Unit Tests
working-directory: hack run: ctest -R unit-
working-directory: build

View File

@ -63,7 +63,9 @@ add_custom_target(cdbg ALL
BYPRODUCTS cdbg BYPRODUCTS cdbg
) )
add_test(NAME unittest COMMAND go test -race -count=3 ./... WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_test(NAME unit-main COMMAND go test -race -count=3 ./... WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME unittest-hack COMMAND go test -race -count=3 ./... WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/hack) add_test(NAME unit-hack COMMAND go test -race -count=3 ./... WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/hack)
add_test(NAME integrationtest COMMAND go test -v -tags integration ./test/ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_test(NAME integration-coord COMMAND go test -v -tags integration ./test/ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_test(NAME etcd-unittest COMMAND go test -v --race -cover -count=3 -tags integration WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/coordinator/store/) add_test(NAME integration-mount COMMAND bash -c "go test -tags integration -c ./test/ && sudo ./test.test -test.v -v 9" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/mount)
add_test(NAME integration-dm COMMAND bash -c "go test -tags integration -c ./test/ && sudo ./test.test -test.v" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/state)
add_test(NAME integration-etcd COMMAND go test -v --race -cover -count=3 -tags integration WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/coordinator/store/)

View File

@ -55,6 +55,14 @@ cmake ..
make -j`nproc` make -j`nproc`
``` ```
## Testing
You can run all integration and unitttests like this:
```sh
ctest -j `nproc`
```
## Cloud credentials ## Cloud credentials
Using the CLI requires the user to make authorized API calls to the CSP API. See the [docs](https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=cloud-credentials) for configuration. Using the CLI requires the user to make authorized API calls to the CSP API. See the [docs](https://constellation-docs.edgeless.systems/6c320851-bdd2-41d5-bf10-e27427398692/#/getting-started/install?id=cloud-credentials) for configuration.