mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-11 07:29:29 -05:00
ci: use bazel for unittests
This commit is contained in:
parent
b467327128
commit
c98644df2b
10
.github/workflows/test-unittest.yml
vendored
10
.github/workflows/test-unittest.yml
vendored
@ -24,8 +24,6 @@ on:
|
||||
jobs:
|
||||
test-linux:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: True
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
@ -48,12 +46,10 @@ jobs:
|
||||
working-directory: build
|
||||
env:
|
||||
TMPDIR: ${{ runner.temp }}
|
||||
run: ctest -R unit
|
||||
run: bazelisk test //... --test_output=errors
|
||||
|
||||
test-darwin:
|
||||
runs-on: macos-12
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: True
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
@ -67,7 +63,7 @@ jobs:
|
||||
cache: true
|
||||
|
||||
- name: CLI Unit Tests
|
||||
run: go test -race -count=3 ./cli/...
|
||||
run: bazelisk test //cli/... --test_output=errors
|
||||
|
||||
- name: cdbg/debugd Unit Tests
|
||||
run: go test -race -count=3 ./debugd/...
|
||||
run: bazelisk test //debugd/... --test_output=errors
|
||||
|
@ -1,88 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
project(constellation LANGUAGES C)
|
||||
set(CLI_BUILD_TAGS "" CACHE STRING "Tags passed to go build of Constellation CLI.")
|
||||
set(BAZEL "bazel" CACHE STRING "Path to bazel binary.")
|
||||
|
||||
enable_testing()
|
||||
|
||||
#
|
||||
# disk-mapper
|
||||
#
|
||||
add_custom_target(disk-mapper ALL
|
||||
COMMAND ${BAZEL} build //disk-mapper/cmd:disk-mapper_linux_amd64
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //disk-mapper/cmd:disk-mapper_linux_amd64\) ${CMAKE_BINARY_DIR}/disk-mapper
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/disk-mapper
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS disk-mapper
|
||||
)
|
||||
|
||||
#
|
||||
# measurement-reader
|
||||
#
|
||||
add_custom_target(measurement-reader ALL
|
||||
COMMAND ${BAZEL} build //measurement-reader/cmd:measurement-reader_linux_amd64
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //measurement-reader/cmd:measurement-reader_linux_amd64\) ${CMAKE_BINARY_DIR}/measurement-reader
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/measurement-reader
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS measurement-reader
|
||||
)
|
||||
|
||||
#
|
||||
# bootstrapper
|
||||
#
|
||||
add_custom_target(bootstrapper ALL
|
||||
COMMAND ${BAZEL} build //bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64\) ${CMAKE_BINARY_DIR}/bootstrapper
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/bootstrapper
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS bootstrapper
|
||||
)
|
||||
|
||||
#
|
||||
# upgrade-agent
|
||||
#
|
||||
add_custom_target(upgrade-agent ALL
|
||||
COMMAND ${BAZEL} build //upgrade-agent/cmd:upgrade_agent_linux_amd64
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //upgrade-agent/cmd:upgrade_agent_linux_amd64\) ${CMAKE_BINARY_DIR}/upgrade-agent
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/upgrade-agent
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS upgrade-agent
|
||||
)
|
||||
|
||||
#
|
||||
# cli
|
||||
#
|
||||
add_custom_target(cli ALL
|
||||
COMMAND ${BAZEL} build --@io_bazel_rules_go//go/config:tags='${CLI_BUILD_TAGS}' //cli:cli_oss_host
|
||||
COMMAND cp \$$\(${BAZEL} cquery --@io_bazel_rules_go//go/config:tags='${CLI_BUILD_TAGS}' --output=files //cli:cli_oss_host\) ${CMAKE_BINARY_DIR}/constellation
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/constellation
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS constellation
|
||||
)
|
||||
|
||||
#
|
||||
# debugd
|
||||
#
|
||||
add_custom_target(debugd ALL
|
||||
COMMAND ${BAZEL} build //debugd/cmd/debugd:debugd_linux_amd64
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //debugd/cmd/debugd:debugd_linux_amd64\) ${CMAKE_BINARY_DIR}/debugd
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/debugd
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS debugd
|
||||
)
|
||||
|
||||
#
|
||||
# cdbg
|
||||
#
|
||||
add_custom_target(cdbg ALL
|
||||
COMMAND ${BAZEL} build //debugd/cmd/cdbg:cdbg_host
|
||||
COMMAND cp \$$\(${BAZEL} cquery --output=files //debugd/cmd/cdbg:cdbg_host\) ${CMAKE_BINARY_DIR}/cdbg
|
||||
COMMAND chmod +w ${CMAKE_BINARY_DIR}/cdbg
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS cdbg
|
||||
)
|
||||
|
||||
add_test(NAME unit COMMAND bash -c "go test -race -count=3 $(go list -f '{{.Dir}}/...' -m | xargs)" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
add_test(NAME integration-node-operator COMMAND make test WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/operators/constellation-node-operator)
|
||||
add_test(NAME integration-csi COMMAND bash -c "go test -tags integration -c ./test/ && sudo ./test.test -test.v" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/csi)
|
||||
add_test(NAME integration-dm COMMAND bash -c "go test -tags integration -c ./test/ && sudo ./test.test -test.v" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/disk-mapper/internal)
|
||||
|
@ -83,13 +83,13 @@ You can also copy the `remote_cache` config from `.bazelrc` to your `~/.bazelrc`
|
||||
|
||||
# Test
|
||||
|
||||
You can run all integration and unitttests like this:
|
||||
You can run all integration like this:
|
||||
|
||||
```sh
|
||||
ctest -j `nproc`
|
||||
```
|
||||
|
||||
You can limit the execution of tests to specific targets with e.g. `ctest -R unit-*` to only execute unit tests.
|
||||
You can limit the execution of tests to specific targets with e.g. `ctest -R integration-node-operator`.
|
||||
|
||||
Some of the tests rely on libvirt and won't work if you don't have a virtualization capable CPU. You can find instructions on setting up libvirt in our [QEMU README](qemu.md).
|
||||
|
||||
|
@ -270,19 +270,27 @@ func TestValidate(t *testing.T) {
|
||||
const azErrCount = 9
|
||||
const gcpErrCount = 6
|
||||
|
||||
// TODO(AB#3132,3u13r): refactor config validation tests
|
||||
// Note that the `cnf.Image = ""` is a hack to align `bazel test` with `go test` behavior
|
||||
// since first does version stamping.
|
||||
testCases := map[string]struct {
|
||||
cnf *Config
|
||||
wantErr bool
|
||||
wantErrCount int
|
||||
}{
|
||||
"default config is not valid": {
|
||||
cnf: Default(),
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.Image = ""
|
||||
return cnf
|
||||
}(),
|
||||
wantErr: true,
|
||||
wantErrCount: defaultErrCount,
|
||||
},
|
||||
"v0 is one error": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.Image = ""
|
||||
cnf.Version = "v0"
|
||||
return cnf
|
||||
}(),
|
||||
@ -292,6 +300,7 @@ func TestValidate(t *testing.T) {
|
||||
"v0 and negative state disk are two errors": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.Image = ""
|
||||
cnf.Version = "v0"
|
||||
cnf.StateDiskSizeGB = -1
|
||||
return cnf
|
||||
@ -302,6 +311,7 @@ func TestValidate(t *testing.T) {
|
||||
"default Azure config is not valid": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.Image = ""
|
||||
cnf.RemoveProviderAndAttestationExcept(cloudprovider.Azure)
|
||||
return cnf
|
||||
}(),
|
||||
@ -329,15 +339,18 @@ func TestValidate(t *testing.T) {
|
||||
return cnf
|
||||
}(),
|
||||
},
|
||||
|
||||
"default GCP config is not valid": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.RemoveProviderAndAttestationExcept(cloudprovider.GCP)
|
||||
cnf.Image = ""
|
||||
return cnf
|
||||
}(),
|
||||
wantErr: true,
|
||||
wantErrCount: gcpErrCount,
|
||||
},
|
||||
|
||||
"GCP config with all required fields is valid": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
@ -356,26 +369,6 @@ func TestValidate(t *testing.T) {
|
||||
return cnf
|
||||
}(),
|
||||
},
|
||||
// TODO: v2.7: remove this test as it should start breaking after v2.6 is released.
|
||||
"k8s vMAJOR.MINOR is valid in v2.7": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.KubernetesVersion = "v1.25"
|
||||
return cnf
|
||||
}(),
|
||||
wantErr: true,
|
||||
wantErrCount: defaultErrCount,
|
||||
},
|
||||
// TODO: v2.7: remove this test as it should start breaking after v2.6 is released.
|
||||
"k8s MAJOR.MINOR is valid in v2.7": {
|
||||
cnf: func() *Config {
|
||||
cnf := Default()
|
||||
cnf.KubernetesVersion = "1.25"
|
||||
return cnf
|
||||
}(),
|
||||
wantErr: true,
|
||||
wantErrCount: defaultErrCount,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user