1 /* 2 Package testutil provides helpers for running the linkerd integration tests. 3 4 All helpers are defined as functions on the TestHelper struct, which you should 5 instantiate once per test, using the NewTestHelper function. Since that function 6 also parses command line flags, it should be called as part of your test's 7 TestMain function. For example: 8 9 package mytest 10 11 import ( 12 "os" 13 "testing" 14 15 "github.com/linkerd/linkerd2/testutil" 16 ) 17 18 var TestHelper *util.TestHelper 19 20 func TestMain(m *testing.M) { 21 TestHelper = util.NewTestHelper() 22 os.Exit(m.Run()) 23 } 24 25 func TestMyTest(t *testing.T) { 26 // add test code here 27 } 28 29 Calling NewTestHelper adds the following command line flags: 30 31 -linkerd string 32 path to the linkerd binary to test 33 -linkerd-namespace string 34 the namespace where linkerd is installed (default "linkerd") 35 -k8s-context string 36 the kubernetes context associated with the test cluster (default "") 37 -integration-tests 38 must be provided to run the integration tests 39 40 Note that the -integration-tests flag must be set when running tests, so that 41 the tests aren't inadvertently executed when unit tests for the project are run. 42 43 TestHelper embeds KubernetesHelper, so all functions defined on KubernetesHelper 44 are also available to instances of TestHelper. See the individual function 45 definitions for details on how to use each helper in tests. 46 */ 47 package testutil 48