Documentation ¶
Overview ¶
Package e2e and its subpacakages define go e2e tests for Nomos.
Running the Tests ¶
A) With make, rebuilding the Nomos image:
$ make go-e2e-test
B) With make, without rebuilding the image:
$ make go-e2e-test-nobuild
C) Directly, without rebuilding:
$ go test ./e2e/... --e2e
Running the tests directly requires running scripts.docker-registry.sh as a one-time setup step.
You can use all of the normal `go test` flags. The `--e2e` is required or else the e2e tests won't run. This lets you run go test ./... to just run unit/integration tests.
Debugging ¶
Use --debug to use the debug mode for tests. In this mode, on failure the test does not destroy the kind cluster and delete the temporary directory. Instead, it prints out where the temporary directory is and how to connect to the kind cluster.
The temporary directory includes:
- All manifests used to install ConfigSync
- The private/public SSH keys to connect to git-server
- The local repository(ies), already configured to talk to git server. Just remember to port-forward to the git-server Pod if you want to read from/write to it.
If you want to stop the test at any time, just use t.FailNow().
Package e2e defines e2e-test-specific imports and flags for use in e2e testing.
Index ¶
Constants ¶
const ( // RunAll runs all tests whether skipped or not RunAll = "runAll" // RunSkipped runs only skipped tests RunSkipped = "runSkipped" // RunDefault runs tests as normal and skips skipped tests RunDefault = "" )
const ( // Kind indicates creating a Kind cluster for testing. Kind = "kind" // GKE indicates using an existing GKE cluster for testing. GKE = "gke" // Kubeconfig provides the context via KUBECONFIG for testing. Kubeconfig = "kube-config" )
const ( // Local indicates using a local git-test-server. Local = "local" // Bitbucket indicates using Bitbucket to host the repositories. Bitbucket = "bitbucket" // Github indicates using GitHub to host the repositories. Github = "github" // GitLab indicates using GitLab to host the repositories. GitLab = "gitlab" // CSR indicates using Google Cloud Source Repositories to host the repositories. CSR = "csr" )
const DefaultImagePrefix = "localhost:5000"
DefaultImagePrefix points to the local docker registry.
Variables ¶
var Debug = flag.Bool("debug", false,
"If true, do not destroy cluster and clean up temporary directory after test.")
Debug enables running the test in debug mode. In debug mode:
- Test execution immediately stops on a call to t.Fatal.
- The test prints the absolute path to the test temporary directory, and not delete it.
- The test prints out how to connect to the kind cluster.
var E2E = flag.Bool("e2e", false,
"If true, run end-to-end tests.")
E2E enables running end-to-end tests.
var GceNode = flag.Bool("gcenode", false,
"If true, run test with 'gcenode' auth type.")
GceNode enables running the e2e tests for 'gcenode' auth type
var GitProvider = flag.String("git-provider", Local,
"The git provider that hosts the Git repositories. Defaults to local")
GitProvider is the provider that hosts the Git repositories.
var ImagePrefix = flag.String("image-prefix", DefaultImagePrefix,
"The prefix to use for Docker images. Defaults to the local Docker registry. Omit the trailing slash.")
ImagePrefix is where the Docker images are stored.
var ImageTag = flag.String("image-tag", "latest",
"The tag to use for Docker images. Defaults to 'latest'")
ImageTag is the tag to use for Docker images.
var Kcc = flag.Bool("kcc", false,
"If true, run kcc tests.")
Kcc enables running the e2e tests for kcc resources.
var KubeConfig = flag.String(Kubeconfig, "",
"The file path to the kubeconfig file. If not set, use the default context.")
KubeConfig specifies the file path to the kubeconfig file.
var KubernetesVersion = flag.String("kubernetes-version", "1.21",
"The version of Kubernetes to create")
KubernetesVersion is the version of Kubernetes to test against. Only has effect when testing against test-created Kind clusters.
var Load = flag.Bool("load", false,
"If true, run load tests.")
Load enables running of load tests.
var Manual = flag.Bool("manual", false,
"Specify that the test is being run manually.")
Manual indicates the test is being run manually. Some tests are not yet safe to be run automatically.
var MultiRepo = flag.Bool("multirepo", false,
"If true, configure multi-repo Config Sync. Otherwise configure mono-repo.")
MultiRepo enables running the tests against multi-repo Config Sync.
"Specify that the test is using a shared test environment instead of fresh installation per test case.")ShareTestEnv indicates whether to share the test env for all test cases. If it is true, we only install nomos once before all tests and tear it down until all tests complete.
var SkipMode = flag.String("skip-mode", "",
"Runs tests as given by the mode, one of \"\", runAll, runSkipped to run normally, run all tests, or run only skipped tests respectively")
SkipMode will only run the skipped multi repo tests.
var Stress = flag.Bool("stress", false,
"If true, run stress tests.")
Stress enables running of stress tests.
var TestCluster = flag.String("test-cluster", Kind, fmt.Sprintf("The cluster config used for testing. Allowed values are: %s and %s. "+ "If --test-cluster=%s, create a Kind cluster. Otherwise use the GKE context specified in %s.", GKE, Kind, Kind, Kubeconfig))
TestCluster specifies the cluster config used for testing.
Functions ¶
func EnableParallel ¶
EnableParallel allows parallel execution of test functions that call t.Parallel if test.parallel is greater than 1.
func RunInParallel ¶
func RunInParallel() bool
RunInParallel indicates whether the test is running in parallel.
Types ¶
This section is empty.