goSDN is tested using unit and integration tests. To run all tests run go test ./...
. Please note is not recommended.
Unit Tests
The unit tests for the nucleus
can be executed with go test ./nucleus
from the repository root.
Parallel execution of Test_httpApi
and TestRun
can cause a race condition if the -race
flag is set. Thus Test_httpApi
needs to be called explicitly.
Using the -v
flag for more verbosity is recommended.
Integration Tests
To run integration tests execute go test ./test/integration
. Note that you have to be connected to the VPN to access the default endpoints.
You can also run the tests locally or in an arbitrary environment. To do so you need to overwrite the default values. This is done via environment variables:
GOSDN_TEST_ENDPOINT
Set this environment variable to point the test to a different gNMI target. Default is 141.100.67.238:6030
GOSDN_TEST_API_ENDPOINT
Set this environment variable to point the test to a different goSDN API endpoint. Default is http://gosdn-latest.apps.ocp.fbi.h-da.de/api
. Note that the API root /api
needs to be part of the variable.
GOSDN_TEST_USER
Set this environment variable to change the default gNMI user. Default is admin
GOSDN_TEST_PASSWORD
Set this environment variable to change the default gNMI user. Default is arista
Run a Single Test
If you want to run a single test you need to use the -run
argument from within the test's directory.
# Example to run `Test_httpApi`
cd nucleus
go test -run Test_httpApi