Documentation
¶
Index ¶
- Constants
- func AssertKubeProxy(t *testing.T, test *Test, localServerPort string, wantError bool)
- func AssertLogBufferNoErrorBundle(t *testing.T, buf *bytes.Buffer)
- func AssertLogBufferWithErrorBundle(t *testing.T, buf *bytes.Buffer)
- func AssertLogMessage(t *testing.T, sett settings.Settings, msgInLog string)
- func AssertLogMessagesCount(t *testing.T, sett settings.Settings, msgInLog string, expected int)
- func AssertNoLogMessage(t *testing.T, sett settings.Settings, msgInLog string)
- func AssertParseFlagsHelp(t *testing.T, params AssertParseFlagsHelpParams)
- func CheckSkipSSHTest(t *testing.T, testName string)
- func CreateDefaultTestSettings(test *Test) settings.Settings
- func CreateDefaultTestSettingsWithAgent(test *Test, agentSockPath string) settings.Settings
- func CreateTestSettingNoDebug(test *Test) settings.Settings
- func DoGetRequest(url string, loop retry.Params, logger *PrefixLogger) (string, error)
- func FakeSession() *session.Session
- func GenerateID(names ...string) string
- func GenerateKeys(test *Test, passphrase string) (string, string, error)
- func GeneratePrivateKey(t *testing.T, passphrase string) string
- func GeneratePrivateKeyWithPublic(t *testing.T, passphrase string) (string, string)
- func GetTestLoopParamsForFailed() retry.Params
- func IncorrectHost() string
- func LogErrorOrAssert(t *testing.T, description string, err error, logger log.Logger)
- func Name(t *testing.T) string
- func PrepareFakeBashibleBundle(t *testing.T, test *Test, entrypoint, bundleDir string) string
- func Ptr[T any](v T) *T
- func RandInvalidPortExclude(_ []int) int
- func RandPassword(n int) string
- func RandPort() int
- func RandPortExclude(exclude []int) int
- func RandRange(min, max int) int
- func RandRangeExclude(min, max int, exclude []int) int
- func RandString(n int) string
- func RunDocker(command ...string) error
- func RunDockerWithOut(command ...string) (string, error)
- func Session(wrapper *TestContainerWrapper, overrides ...SessionOverride) *session.Session
- func SessionWithBastion(wrapper *TestContainerWrapper, bastionWrapper *TestContainerWrapper, ...) *session.Session
- func SetEnvs(t *testing.T, envs map[string]string)
- func Sleep(d time.Duration)
- func TestLogger(opts ...TestOpt) *log.InMemoryLogger
- func WritePubKeyFileForPrivate(test *Test, privateKeyPath string, pubKey string) (string, error)
- type Agent
- type AssertParseFlagsHelpParams
- type ContainerSettings
- type HTTPHandler
- type HTTPServer
- type KINDCluster
- type KINDClusterCreateParams
- type PrefixLogger
- type PrivateKey
- type PublicKey
- type SSHContainer
- func (c *SSHContainer) Connect() error
- func (c *SSHContainer) ContainerSettings() *ContainerSettings
- func (c *SSHContainer) CreateDeckhouseDirs() error
- func (c *SSHContainer) CreateDirectory(path string) error
- func (c *SSHContainer) Disconnect() error
- func (c *SSHContainer) DockerNetworkConnect(isDisconnect bool, name string) error
- func (c *SSHContainer) DownloadKubectl(version string) error
- func (c *SSHContainer) ExecToContainer(description string, command ...string) error
- func (c *SSHContainer) FailAndUpConnection(sleepBeforeConnect time.Duration) error
- func (c *SSHContainer) GetContainerIP() string
- func (c *SSHContainer) GetContainerId() string
- func (c *SSHContainer) GetNetwork() string
- func (c *SSHContainer) GetSSHDConfigPath() string
- func (c *SSHContainer) LocalPortString() string
- func (c *SSHContainer) RemotePort() int
- func (c *SSHContainer) RemotePortString() string
- func (c *SSHContainer) Restart(waitSSHDStarted bool, sleepBeforeStart time.Duration) error
- func (c *SSHContainer) ShortContainerId() string
- func (c *SSHContainer) SoftRestart(waitSSHDStarted bool, sleepBeforeStart time.Duration) error
- func (c *SSHContainer) Start(waitSSHDStarted bool) error
- func (c *SSHContainer) Stop() error
- func (c *SSHContainer) WithExternalNetwork(network string) *SSHContainer
- func (c *SSHContainer) WithVolumes(volumes ...Volume) *SSHContainer
- func (c *SSHContainer) WriteConfig() error
- type SSHContainersForKind
- type SessionOverride
- type Test
- func (s *Test) Cleanup(t *testing.T)
- func (s *Test) CreateFile(content string, executable bool, pathInTestDir ...string) (string, error)
- func (s *Test) CreateFileWithSameSuffix(sourceFile string, content string, executable bool, pathInTestDir ...string) (string, error)
- func (s *Test) CreateTmpFile(content string, executable bool, pathInTestDir ...string) (string, error)
- func (s *Test) FullName() string
- func (s *Test) GenerateID(names ...string) string
- func (s *Test) GetID() string
- func (s *Test) GetLogger() *log.InMemoryLogger
- func (s *Test) IsZero() bool
- func (s *Test) MkSubDirs(dirs ...string) (string, error)
- func (s *Test) MustCreateFile(t *testing.T, content string, executable bool, pathInTestDir ...string) string
- func (s *Test) MustCreateTmpFile(t *testing.T, content string, executable bool, pathInTestDir ...string) string
- func (s *Test) MustCreateUnaccessibleDir(t *testing.T, name string)
- func (s *Test) MustMkSubDirs(t *testing.T, dirs ...string) string
- func (s *Test) Name() string
- func (s *Test) RegisterCleanup(t *testing.T)
- func (s *Test) RunSubTestParallel(t *testing.T)
- func (s *Test) SetSubTest(names ...string) *Test
- func (s *Test) SetTmpDir(dir string) error
- func (s *Test) Settings() settings.Settings
- func (s *Test) TmpDir() string
- func (s *Test) TryToSkipIntegrationTest(t *testing.T)
- func (s *Test) WithAuthSock(p string) *Test
- func (s *Test) WithEnvsPrefix(p string) *Test
- func (s *Test) WrapError(format string, args ...any) error
- func (s *Test) WrapErrorWithAfterName(aftername, format string, args ...any) error
- type TestContainerWrapper
- type TestContainerWrapperSettings
- type TestContainerWrapperSettingsOpts
- func WithAuthSettings(testContainer *TestContainerWrapper) TestContainerWrapperSettingsOpts
- func WithConnectToContainerNetwork(testContainer *TestContainerWrapper) TestContainerWrapperSettingsOpts
- func WithContainerName(name string) TestContainerWrapperSettingsOpts
- func WithLocalPort(port int) TestContainerWrapperSettingsOpts
- func WithNoGeneratePrivateKeys() TestContainerWrapperSettingsOpts
- func WithNoPassword() TestContainerWrapperSettingsOpts
- func WithNoStartContainer() TestContainerWrapperSettingsOpts
- func WithNoSudo() TestContainerWrapperSettingsOpts
- func WithNoWaitStartingSSHDAfterStartContainer() TestContainerWrapperSettingsOpts
- func WithNoWriteSSHDConfig() TestContainerWrapperSettingsOpts
- func WithPassword(password string) TestContainerWrapperSettingsOpts
- func WithUserName(name string) TestContainerWrapperSettingsOpts
- func WithVolumes(v []Volume) TestContainerWrapperSettingsOpts
- type TestFlagsParser
- type TestFlagsParserHelpProvider
- type TestOpt
- type Volume
Constants ¶
View Source
const HealthzPath = "/healthz"
View Source
const (
KindBinary = "../../../bin/kind"
)
View Source
const PrivateKeysRoot = "private_keys"
Variables ¶
This section is empty.
Functions ¶
func AssertKubeProxy ¶
func AssertLogMessage ¶
func AssertLogMessagesCount ¶
func AssertNoLogMessage ¶
func AssertParseFlagsHelp ¶
func AssertParseFlagsHelp(t *testing.T, params AssertParseFlagsHelpParams)
func CheckSkipSSHTest ¶
func DoGetRequest ¶
func FakeSession ¶
func GenerateID ¶
func GenerateKeys ¶
helper func to generate SSH keys
func IncorrectHost ¶
func IncorrectHost() string
func LogErrorOrAssert ¶
func RandInvalidPortExclude ¶
func RandPassword ¶
func RandPortExclude ¶
func RandRangeExclude ¶
func RandString ¶
func RunDockerWithOut ¶
func Session ¶
func Session(wrapper *TestContainerWrapper, overrides ...SessionOverride) *session.Session
func SessionWithBastion ¶
func SessionWithBastion(wrapper *TestContainerWrapper, bastionWrapper *TestContainerWrapper, overrides ...SessionOverride) *session.Session
func TestLogger ¶
func TestLogger(opts ...TestOpt) *log.InMemoryLogger
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func StartAgent ¶
func StartTestAgent ¶
func StartTestAgent(t *testing.T, wrapper *TestContainerWrapper) *Agent
func (*Agent) AddKey ¶
func (a *Agent) AddKey(key PrivateKey) error
func (*Agent) RegisterCleanup ¶
func (*Agent) RemoveKey ¶
func (a *Agent) RemoveKey(key PrivateKey) error
type AssertParseFlagsHelpParams ¶
type AssertParseFlagsHelpParams struct {
Name string
Provider TestFlagsParserHelpProvider
ExpectedFlags int
}
type ContainerSettings ¶
type ContainerSettings struct {
*Test
PublicKey *PublicKey
Password string
Username string
NodeTmpPath string
LocalPort int
SudoAccess bool
ContainerName string
AdditionalVolumes []Volume
}
func (*ContainerSettings) HasPassword ¶
func (s *ContainerSettings) HasPassword() bool
func (*ContainerSettings) HasPublicKey ¶
func (s *ContainerSettings) HasPublicKey() bool
func (*ContainerSettings) HasPublicKeyContent ¶
func (s *ContainerSettings) HasPublicKeyContent() bool
func (*ContainerSettings) HasPublicKeyPath ¶
func (s *ContainerSettings) HasPublicKeyPath() bool
func (*ContainerSettings) LocalPortString ¶
func (s *ContainerSettings) LocalPortString() string
func (*ContainerSettings) String ¶
func (s *ContainerSettings) String() string
type HTTPHandler ¶
type HTTPHandler struct {
Path string
Handle func(w http.ResponseWriter, r *http.Request, logger *PrefixLogger)
}
func NewSimpleHTTPHandler ¶
func NewSimpleHTTPHandler(path string, response string) *HTTPHandler
func (*HTTPHandler) IsValid ¶
func (h *HTTPHandler) IsValid() error
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func MustStartHTTPServer ¶
func MustStartHTTPServer(t *testing.T, test *Test, port int, handlers ...*HTTPHandler) *HTTPServer
func NewHTTPServer ¶
func NewHTTPServer(port int, logger *log.InMemoryLogger, handlers ...*HTTPHandler) *HTTPServer
func (*HTTPServer) AddHandler ¶
func (s *HTTPServer) AddHandler(handler *HTTPHandler)
func (*HTTPServer) RegisterCleanup ¶
func (s *HTTPServer) RegisterCleanup(t *testing.T)
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start(waitStart bool) error
func (*HTTPServer) Stop ¶
func (s *HTTPServer) Stop() error
func (*HTTPServer) WithLogPrefix ¶
func (s *HTTPServer) WithLogPrefix(p string) *HTTPServer
type KINDCluster ¶
type KINDCluster struct {
Name string
ControlPlaneIP string
ControlPlanePort string
// contains filtered or unexported fields
}
func CreateKINDCluster ¶
func CreateKINDCluster(t *testing.T, params *KINDClusterCreateParams) *KINDCluster
func (*KINDCluster) Delete ¶
func (c *KINDCluster) Delete() error
func (*KINDCluster) Kubeconfig ¶
func (c *KINDCluster) Kubeconfig() string
func (*KINDCluster) KubeconfigWithIP ¶
func (c *KINDCluster) KubeconfigWithIP(ip string, port string) string
KubeconfigWithIP ip and port can empty if empty returns raw
func (*KINDCluster) RESTConfig ¶
func (c *KINDCluster) RESTConfig() (*rest.Config, error)
func (*KINDCluster) RegisterCleanup ¶
func (c *KINDCluster) RegisterCleanup(t *testing.T)
type KINDClusterCreateParams ¶
type KINDClusterCreateParams struct {
Test *Test
ClusterName string
Containers []*SSHContainersForKind
NoPrepareLocalKubectlInSSHContainer bool
}
type PrefixLogger ¶
func NewPrefixLogger ¶
func NewPrefixLogger(logger log.Logger) *PrefixLogger
func (*PrefixLogger) Error ¶
func (l *PrefixLogger) Error(f string, args ...any)
func (*PrefixLogger) Info ¶
func (l *PrefixLogger) Info(f string, args ...any)
func (*PrefixLogger) Log ¶
func (l *PrefixLogger) Log(write func(string, ...any), f string, args ...any)
func (*PrefixLogger) WithPrefix ¶
func (l *PrefixLogger) WithPrefix(p string) *PrefixLogger
type PrivateKey ¶
type SSHContainer ¶
type SSHContainer struct {
// contains filtered or unexported fields
}
func NewSSHContainer ¶
func NewSSHContainer(settings *ContainerSettings) (*SSHContainer, error)
func (*SSHContainer) Connect ¶
func (c *SSHContainer) Connect() error
func (*SSHContainer) ContainerSettings ¶
func (c *SSHContainer) ContainerSettings() *ContainerSettings
func (*SSHContainer) CreateDeckhouseDirs ¶
func (c *SSHContainer) CreateDeckhouseDirs() error
func (*SSHContainer) CreateDirectory ¶
func (c *SSHContainer) CreateDirectory(path string) error
func (*SSHContainer) Disconnect ¶
func (c *SSHContainer) Disconnect() error
func (*SSHContainer) DockerNetworkConnect ¶
func (c *SSHContainer) DockerNetworkConnect(isDisconnect bool, name string) error
func (*SSHContainer) DownloadKubectl ¶
func (c *SSHContainer) DownloadKubectl(version string) error
func (*SSHContainer) ExecToContainer ¶
func (c *SSHContainer) ExecToContainer(description string, command ...string) error
func (*SSHContainer) FailAndUpConnection ¶
func (c *SSHContainer) FailAndUpConnection(sleepBeforeConnect time.Duration) error
func (*SSHContainer) GetContainerIP ¶
func (c *SSHContainer) GetContainerIP() string
func (*SSHContainer) GetContainerId ¶
func (c *SSHContainer) GetContainerId() string
func (*SSHContainer) GetNetwork ¶
func (c *SSHContainer) GetNetwork() string
func (*SSHContainer) GetSSHDConfigPath ¶
func (c *SSHContainer) GetSSHDConfigPath() string
func (*SSHContainer) LocalPortString ¶
func (c *SSHContainer) LocalPortString() string
func (*SSHContainer) RemotePort ¶
func (c *SSHContainer) RemotePort() int
func (*SSHContainer) RemotePortString ¶
func (c *SSHContainer) RemotePortString() string
func (*SSHContainer) Restart ¶
func (c *SSHContainer) Restart(waitSSHDStarted bool, sleepBeforeStart time.Duration) error
func (*SSHContainer) ShortContainerId ¶
func (c *SSHContainer) ShortContainerId() string
func (*SSHContainer) SoftRestart ¶
func (c *SSHContainer) SoftRestart(waitSSHDStarted bool, sleepBeforeStart time.Duration) error
func (*SSHContainer) Start ¶
func (c *SSHContainer) Start(waitSSHDStarted bool) error
func (*SSHContainer) Stop ¶
func (c *SSHContainer) Stop() error
func (*SSHContainer) WithExternalNetwork ¶
func (c *SSHContainer) WithExternalNetwork(network string) *SSHContainer
func (*SSHContainer) WithVolumes ¶
func (c *SSHContainer) WithVolumes(volumes ...Volume) *SSHContainer
func (*SSHContainer) WriteConfig ¶
func (c *SSHContainer) WriteConfig() error
force AllowTcpForwarding yes to allow connection throufh bastion
type SSHContainersForKind ¶
type SSHContainersForKind struct {
Client connection.SSHClient
Container *TestContainerWrapper
}
type SessionOverride ¶
func OverrideSessionWithIncorrectBastionPort ¶
func OverrideSessionWithIncorrectBastionPort(wrappers ...*TestContainerWrapper) SessionOverride
func OverrideSessionWithIncorrectPort ¶
func OverrideSessionWithIncorrectPort(wrappers ...*TestContainerWrapper) SessionOverride
type Test ¶
type Test struct {
Logger *log.InMemoryLogger
// contains filtered or unexported fields
}
func (*Test) CreateFile ¶
func (*Test) CreateFileWithSameSuffix ¶
func (*Test) CreateTmpFile ¶
func (*Test) GenerateID ¶
func (*Test) GetLogger ¶
func (s *Test) GetLogger() *log.InMemoryLogger
func (*Test) MustCreateFile ¶
func (*Test) MustCreateTmpFile ¶
func (*Test) MustCreateUnaccessibleDir ¶
func (*Test) RegisterCleanup ¶
func (*Test) RunSubTestParallel ¶
func (*Test) SetSubTest ¶
func (*Test) TryToSkipIntegrationTest ¶
func (*Test) WithAuthSock ¶
func (*Test) WithEnvsPrefix ¶
type TestContainerWrapper ¶
type TestContainerWrapper struct {
Container *SSHContainer
Settings *TestContainerWrapperSettings
PrivateKeyPath string
}
func NewTestContainerWrapper ¶
func NewTestContainerWrapper(t *testing.T, test *Test, opts ...TestContainerWrapperSettingsOpts) *TestContainerWrapper
func (*TestContainerWrapper) AgentPrivateKeys ¶
func (c *TestContainerWrapper) AgentPrivateKeys() []session.AgentPrivateKey
func (*TestContainerWrapper) Cleanup ¶
func (c *TestContainerWrapper) Cleanup(t *testing.T)
func (*TestContainerWrapper) ContainerIP ¶
func (c *TestContainerWrapper) ContainerIP() string
func (*TestContainerWrapper) LocalPort ¶
func (c *TestContainerWrapper) LocalPort() int
func (*TestContainerWrapper) PublicKeyPath ¶
func (c *TestContainerWrapper) PublicKeyPath() string
type TestContainerWrapperSettingsOpts ¶
type TestContainerWrapperSettingsOpts func(container *TestContainerWrapperSettings)
func WithAuthSettings ¶
func WithAuthSettings(testContainer *TestContainerWrapper) TestContainerWrapperSettingsOpts
func WithConnectToContainerNetwork ¶
func WithConnectToContainerNetwork(testContainer *TestContainerWrapper) TestContainerWrapperSettingsOpts
func WithContainerName ¶
func WithContainerName(name string) TestContainerWrapperSettingsOpts
func WithLocalPort ¶
func WithLocalPort(port int) TestContainerWrapperSettingsOpts
func WithNoGeneratePrivateKeys ¶
func WithNoGeneratePrivateKeys() TestContainerWrapperSettingsOpts
func WithNoPassword ¶
func WithNoPassword() TestContainerWrapperSettingsOpts
func WithNoStartContainer ¶
func WithNoStartContainer() TestContainerWrapperSettingsOpts
func WithNoSudo ¶
func WithNoSudo() TestContainerWrapperSettingsOpts
func WithNoWaitStartingSSHDAfterStartContainer ¶
func WithNoWaitStartingSSHDAfterStartContainer() TestContainerWrapperSettingsOpts
func WithNoWriteSSHDConfig ¶
func WithNoWriteSSHDConfig() TestContainerWrapperSettingsOpts
func WithPassword ¶
func WithPassword(password string) TestContainerWrapperSettingsOpts
func WithUserName ¶
func WithUserName(name string) TestContainerWrapperSettingsOpts
func WithVolumes ¶
func WithVolumes(v []Volume) TestContainerWrapperSettingsOpts
type TestFlagsParser ¶
type TestFlagsParserHelpProvider ¶
type TestFlagsParserHelpProvider func(s settings.Settings, envsPrefix string) TestFlagsParser
type TestOpt ¶
type TestOpt func(opts *testOpts)
func TestIsIntegration ¶
func TestWithAuthSock ¶
func TestWithDebug ¶
func TestWithLoggerBuffer ¶
func TestWithParallelRun ¶
func TestWithPrettyLogger ¶
Click to show internal directories.
Click to hide internal directories.