Documentation
¶
Index ¶
- Constants
- Variables
- func Configure() func()
- func ConfigureGit() error
- func ConfigureGitalyGit2GoBin(t testing.TB, cfg config.Cfg)
- func ConfigureGitalyHooksBin(t testing.TB, cfg config.Cfg)
- func ConfigureGitalyLfsSmudge(t *testing.T, outputDir string)
- func ConfigureGitalySSHBin(t testing.TB, cfg config.Cfg)
- func ConfigureRuby(cfg *config.Cfg) error
- func Context(opts ...ContextOpt) (context.Context, func())
- func CopyFile(t testing.TB, src, dst string)
- func DiscardTestEntry(tb testing.TB) *log.Entry
- func DiscardTestLogger(tb testing.TB) *log.Logger
- func GenerateCerts(t *testing.T) (string, string)
- func GetLocalhostListener(t testing.TB) (net.Listener, string)
- func GetTemporaryGitalySocketFileName(t testing.TB) string
- func GitLabTestCommit(id string) *gitalypb.GitCommit
- func GitalyServersMetadataFromCfg(t testing.TB, cfg config.Cfg) metadata.MD
- func GitlabTestStoragePath() string
- func MergeIncomingMetadata(ctx context.Context, md ...metadata.MD) context.Context
- func MergeOutgoingMetadata(ctx context.Context, md ...metadata.MD) context.Context
- func ModifyEnvironment(t testing.TB, key string, value string) func()
- func MustClose(t testing.TB, closer io.Closer)
- func MustHaveNoChildProcess()
- func MustReadFile(t testing.TB, filename string) []byte
- func MustRunCommand(t testing.TB, stdin io.Reader, name string, args ...string) []byte
- func NewGitlabTestServer(t testing.TB, options GitlabTestServerOptions) (url string, cleanup func())
- func NewHealthServerWithListener(t testing.TB, listener net.Listener) *health.Server
- func NewServerWithHealth(t testing.TB, socketName string) *health.Server
- func ReceiveEOFWithTimeout(t testing.TB, errorFunc func() error)
- func RequireGrpcError(t testing.TB, err error, expectedCode codes.Code)
- func SetCtxGrpcMethod(ctx context.Context, method string) context.Context
- func SetupAndStartGitlabServer(t testing.TB, shellDir string, c *GitlabTestServerOptions) (string, func())
- func TempDir(t testing.TB) string
- func WriteExecutable(t testing.TB, path string, content []byte)
- func WriteShellSecretFile(t testing.TB, dir, secretToken string) string
- func WriteTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, password, secretFile string) (string, func())
- type Cleanup
- type ContextOpt
- type FeatureSet
- type FeatureSets
- type GitlabTestServerOptions
- type HTTPSettings
Constants ¶
const ( // RepositoryAuthToken is the default token used to authenticate // against other Gitaly servers. It is inject as part of the // GitalyServers metadata. RepositoryAuthToken = "the-secret-token" // DefaultStorageName is the default name of the Gitaly storage. DefaultStorageName = "default" )
Variables ¶
var NewTestLogger = DiscardTestLogger
NewTestLogger creates logger that should be used in the tests.
Functions ¶
func Configure ¶
func Configure() func()
Configure sets up the global test configuration. On failure, terminates the program.
func ConfigureGitalyGit2GoBin ¶
ConfigureGitalyGit2GoBin configures the gitaly-git2go command for tests
func ConfigureGitalyHooksBin ¶
ConfigureGitalyHooksBin builds gitaly-hooks command for tests for the cfg.
func ConfigureGitalyLfsSmudge ¶
ConfigureGitalyLfsSmudge configures the gitaly-lfs-smudge command for tests
func ConfigureGitalySSHBin ¶
ConfigureGitalySSHBin builds gitaly-ssh command for tests for the cfg.
func ConfigureRuby ¶
ConfigureRuby configures Ruby settings for test purposes at run time.
func Context ¶
func Context(opts ...ContextOpt) (context.Context, func())
Context returns a cancellable context.
func DiscardTestEntry ¶
DiscardTestEntry creates a logrus entry that discards everything.
func DiscardTestLogger ¶
DiscardTestLogger created a logrus hook that discards everything.
func GenerateCerts ¶
GenerateCerts creates a certificate that can be used to establish TLS protected TCP connection. It returns paths to the file with the certificate and its private key.
func GetLocalhostListener ¶
GetLocalhostListener listens on the next available TCP port and returns the listener and the localhost address (host:port) string.
func GetTemporaryGitalySocketFileName ¶
GetTemporaryGitalySocketFileName will return a unique, useable socket file name
func GitLabTestCommit ¶
GitLabTestCommit provides a key value lookup for commits in the GitLab-Test repository
func GitalyServersMetadataFromCfg ¶
GitalyServersMetadataFromCfg returns a metadata pair for gitaly-servers to be used in inter-gitaly operations.
func GitlabTestStoragePath ¶
func GitlabTestStoragePath() string
GitlabTestStoragePath returns the storage path to the gitlab-test repo.
func MergeIncomingMetadata ¶
MergeIncomingMetadata merges provided metadata-s and returns context with resulting value.
func MergeOutgoingMetadata ¶
MergeOutgoingMetadata merges provided metadata-s and returns context with resulting value.
func ModifyEnvironment ¶
ModifyEnvironment will change an environment variable and return a func suitable for `defer` to change the value back.
func MustClose ¶
MustClose calls Close() on the Closer and fails the test in case it returns an error. This function is useful when closing via `defer`, as a simple `defer require.NoError(t, closer.Close())` would cause `closer.Close()` to be executed early already.
func MustHaveNoChildProcess ¶
func MustHaveNoChildProcess()
MustHaveNoChildProcess panics if it finds a running or finished child process. It waits for 2 seconds for processes to be cleaned up by other goroutines.
func MustReadFile ¶
MustReadFile returns the content of a file or fails at once.
func MustRunCommand ¶
MustRunCommand runs a command with an optional standard input and returns the standard output, or fails.
func NewGitlabTestServer ¶
func NewGitlabTestServer(t testing.TB, options GitlabTestServerOptions) (url string, cleanup func())
NewGitlabTestServer returns a mock gitlab server that responds to the hook api endpoints
func NewHealthServerWithListener ¶
NewHealthServerWithListener creates a new gRPC server with the health server set up. It will listen on the given listener.
func NewServerWithHealth ¶
NewServerWithHealth creates a new gRPC server with the health server set up. It will listen on the socket identified by `socketName`.
func ReceiveEOFWithTimeout ¶
ReceiveEOFWithTimeout reads to the end of the stream and will throw an error if a deadlock is suspected
func RequireGrpcError ¶
RequireGrpcError asserts the passed err is of the same code as expectedCode.
func SetCtxGrpcMethod ¶
SetCtxGrpcMethod will set the gRPC context value for the proper key responsible for an RPC full method name. This directly corresponds to the gRPC function responsible for extracting the method: https://godoc.org/google.golang.org/grpc#Method
func SetupAndStartGitlabServer ¶
func SetupAndStartGitlabServer(t testing.TB, shellDir string, c *GitlabTestServerOptions) (string, func())
SetupAndStartGitlabServer creates a new GitlabTestServer, starts it and sets up the gitlab-shell secret.
func WriteExecutable ¶
WriteExecutable ensures that the parent directory exists, and writes an executable with provided content
func WriteShellSecretFile ¶
WriteShellSecretFile writes a .gitlab_shell_secret file in the specified directory
func WriteTemporaryGitalyConfigFile ¶
func WriteTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, password, secretFile string) (string, func())
WriteTemporaryGitalyConfigFile writes a gitaly toml file into a temporary directory. It returns the path to the file as well as a cleanup function
Types ¶
type Cleanup ¶
type Cleanup func()
Cleanup functions should be called in a defer statement immediately after they are returned from a test helper
type ContextOpt ¶
ContextOpt returns a new context instance with the new additions to it.
func ContextWithLogger ¶
func ContextWithLogger(logger *log.Entry) ContextOpt
ContextWithLogger allows to inject provided logger into the context.
func ContextWithTimeout ¶
func ContextWithTimeout(duration time.Duration) ContextOpt
ContextWithTimeout allows to set provided timeout to the context.
type FeatureSet ¶
type FeatureSet struct {
// contains filtered or unexported fields
}
FeatureSet is a representation of a set of features that should be disabled. This is useful in situations where a test needs to test any combination of features toggled on and off. It is designed to disable features as all features are enabled by default, please see: testhelper.Context()
func (FeatureSet) Desc ¶
func (f FeatureSet) Desc() string
Desc describes the feature such that it is suitable as a testcase description.
type FeatureSets ¶
type FeatureSets []FeatureSet
FeatureSets is a slice containing many FeatureSets
func NewFeatureSets ¶
func NewFeatureSets(goFeatures []featureflag.FeatureFlag, rubyFeatures ...featureflag.FeatureFlag) FeatureSets
NewFeatureSets takes a slice of go feature flags, and an optional variadic set of ruby feature flags and returns a FeatureSets slice
type GitlabTestServerOptions ¶
type GitlabTestServerOptions struct {
User, Password, SecretToken string
GLID string
GLRepository string
Changes string
PostReceiveMessages []string
PostReceiveAlerts []string
PostReceiveCounterDecreased bool
UnixSocket bool
LfsStatusCode int
LfsOid string
LfsBody string
Protocol string
GitPushOptions []string
GitObjectDir string
GitAlternateObjectDirs []string
RepoPath string
RelativeURLRoot string
GlRepository string
ClientCACertPath string // used to verify client certs are valid
ServerCertPath string
ServerKeyPath string
}
GitlabTestServerOptions is a config for a mock gitlab server containing expected values
type HTTPSettings ¶
HTTPSettings contains fields for http settings