func init() { … } type TearDownFunc … type TestServerInstanceOptions … type TestServer … type Logger … // NewDefaultTestServerOptions Default options for TestServer instances func NewDefaultTestServerOptions() *TestServerInstanceOptions { … } // StartTestServer starts a apiextensions-apiserver. A rest client config and a tear-down func, // and location of the tmpdir are returned. // // Note: we return a tear-down func instead of a stop channel because the later will leak temporary // files that because Golang testing's call to os.Exit will not give a stop channel go routine // enough time to remove temporary files. func StartTestServer(t Logger, _ *TestServerInstanceOptions, customFlags []string, storageConfig *storagebackend.Config) (result TestServer, err error) { … } // StartTestServerOrDie calls StartTestServer t.Fatal if it does not succeed. func StartTestServerOrDie(t Logger, instanceOptions *TestServerInstanceOptions, flags []string, storageConfig *storagebackend.Config) *TestServer { … } func createLocalhostListenerOnFreePort() (net.Listener, int, error) { … } // pkgPath returns the absolute file path to this package's directory. With go // test, we can just look at the runtime call stack. However, bazel compiles go // binaries with the -trimpath option so the simple approach fails however we // can consult environment variables to derive the path. // // The approach taken here works for both go test and bazel on the assumption // that if and only if trimpath is passed, we are running under bazel. func pkgPath(t Logger) (string, error) { … }