Documentation
¶
Index ¶
- Constants
- func AsByteTimelineEntries(b ...byte) []testReaderTimelineEntry
- func AsErrorTimelineEntry(err error) testReaderTimelineEntry
- func CreateTestSessionDir() (string, error)
- func FindAllMatching(ss []string, re *regexp.Regexp) [][]string
- func GetRandLetters(t *testing.T, count int) string
- func GetTestContext(t *testing.T, testTimeout time.Duration) (context.Context, context.CancelFunc)
- func LengthNotChanging[S ~[]E, E any](ctx context.Context, s *S, period time.Duration, numPeriods uint, ...) error
- func NewLogForTesting(name string) logr.Logger
- func SkipIfNotEnableAdvancedNetworking(t *testing.T)
- func SkipIfNotEnabledAdvancedCertificates(t *testing.T)
- func SkipIfTrueContainerOrchestratorNotEnabled(t *testing.T)
- func TestTempDir() string
- func TestTempRoot() string
- type BufferWriter
- func (bw *BufferWriter) AddTarget(t io.Writer) error
- func (bw *BufferWriter) Bytes() []byte
- func (bw *BufferWriter) Chunks() []Chunk
- func (bw *BufferWriter) ChunksLen() int
- func (bw *BufferWriter) Close() error
- func (bw *BufferWriter) Closed() <-chan struct{}
- func (bw *BufferWriter) FailNextSync(err error)
- func (bw *BufferWriter) FailNextWrite(err error)
- func (bw *BufferWriter) Lines(sep []byte) [][]byte
- func (bw *BufferWriter) Sync() error
- func (bw *BufferWriter) Write(p []byte) (int, error)
- type Chunk
- type MockLoggerSink
- func (m *MockLoggerSink) EnableErrorCall()
- func (m *MockLoggerSink) Enabled(level int) bool
- func (m *MockLoggerSink) Error(err error, msg string, keysAndValues ...interface{})
- func (m *MockLoggerSink) Info(level int, msg string, keysAndValues ...interface{})
- func (m *MockLoggerSink) Init(info logr.RuntimeInfo)
- func (m *MockLoggerSink) WithName(name string) logr.LogSink
- func (m *MockLoggerSink) WithValues(keysAndValues ...interface{}) logr.LogSink
- type TestReader
- type ThreadSafeBuffer
Constants ¶
const ( // Set to true to enable advanced networking tests such as those that require access to all network interfaces // and try to open ports that are accessible to requests originating from outside of the machine or tests // that evaluate network performance against a baseline (these are unreliable on CI machines). // This is disabled by default because on Windows it causes a security prompt every time the tests are run. DCP_TEST_ENABLE_ADVANCED_NETWORKING = "DCP_TEST_ENABLE_ADVANCED_NETWORKING" // Set to true to enable advanced certificate file tests such as those that require openssl installed to // verify behavior. DCP_TEST_ENABLE_ADVANCED_CERTIFICATES = "DCP_TEST_ENABLE_ADVANCED_CERTIFICATES" // Set to true to enable tests that require real container orchestrator (Docker or Podman). DCP_TEST_ENABLE_TRUE_CONTAINER_ORCHESTRATOR = "DCP_TEST_ENABLE_TRUE_CONTAINER_ORCHESTRATOR" // Used by VS Code to disable skipping tests when they are run with the debugger. DCP_TEST_VS_CODE_DEBUGGER = "DCP_TEST_VS_CODE_DEBUGGER" )
Variables ¶
This section is empty.
Functions ¶
func AsByteTimelineEntries ¶
func AsByteTimelineEntries(b ...byte) []testReaderTimelineEntry
func AsErrorTimelineEntry ¶
func AsErrorTimelineEntry(err error) testReaderTimelineEntry
func CreateTestSessionDir ¶
Creates a session directory for use in tests.
func FindAllMatching ¶
FindAllMatching tries the passed regular expression on all strings in the passed slice and returns the result for re.FindStringSubmatch() for each string in the slice that matches. For each match, the slice returned will contain the full match, followed by all captured groups (subexpressions).
func GetTestContext ¶
func LengthNotChanging ¶
func LengthNotChanging[S ~[]E, E any](ctx context.Context, s *S, period time.Duration, numPeriods uint, lock sync.Locker) error
Verify that the length of a slice does not change over several periods of time. The function is taking a pointer to the slice because the slice might be manipulated by other goroutines.
func NewLogForTesting ¶
func TestTempDir ¶
func TestTempDir() string
Returns a temporary directory path for use in tests. If session folder is set in the environment, returns that. Otherwise, returns the temporary directory root path.
func TestTempRoot ¶
func TestTempRoot() string
Returns temporary directory root path for use in tests. Agents running tests in CI pipelines often require that tests use temporary directory that is different from what TEMP or TMPDIR environment variables point to. This function takes care of that.
Types ¶
type BufferWriter ¶
type BufferWriter struct {
// contains filtered or unexported fields
}
func NewBufferWriter ¶
func NewBufferWriter() *BufferWriter
func (*BufferWriter) Bytes ¶
func (bw *BufferWriter) Bytes() []byte
func (*BufferWriter) Chunks ¶
func (bw *BufferWriter) Chunks() []Chunk
func (*BufferWriter) ChunksLen ¶
func (bw *BufferWriter) ChunksLen() int
func (*BufferWriter) Close ¶
func (bw *BufferWriter) Close() error
func (*BufferWriter) Closed ¶
func (bw *BufferWriter) Closed() <-chan struct{}
func (*BufferWriter) FailNextSync ¶
func (bw *BufferWriter) FailNextSync(err error)
FailNextSync causes the next Sync operation to fail with an error. After the failure, subsequent syncs will succeed normally.
func (*BufferWriter) FailNextWrite ¶
func (bw *BufferWriter) FailNextWrite(err error)
FailNextWrite causes the next Write operation to fail with an error. After the failure, subsequent writes will succeed normally.
func (*BufferWriter) Lines ¶
func (bw *BufferWriter) Lines(sep []byte) [][]byte
func (*BufferWriter) Sync ¶
func (bw *BufferWriter) Sync() error
type MockLoggerSink ¶
func NewMockLoggerSink ¶
func NewMockLoggerSink() *MockLoggerSink
func (*MockLoggerSink) EnableErrorCall ¶
func (m *MockLoggerSink) EnableErrorCall()
func (*MockLoggerSink) Enabled ¶
func (m *MockLoggerSink) Enabled(level int) bool
func (*MockLoggerSink) Error ¶
func (m *MockLoggerSink) Error(err error, msg string, keysAndValues ...interface{})
func (*MockLoggerSink) Info ¶
func (m *MockLoggerSink) Info(level int, msg string, keysAndValues ...interface{})
func (*MockLoggerSink) Init ¶
func (m *MockLoggerSink) Init(info logr.RuntimeInfo)
func (*MockLoggerSink) WithValues ¶
func (m *MockLoggerSink) WithValues(keysAndValues ...interface{}) logr.LogSink
type TestReader ¶
type TestReader struct {
// contains filtered or unexported fields
}
func NewTestReader ¶
func NewTestReader() *TestReader
func (*TestReader) AddEntry ¶
func (tr *TestReader) AddEntry(entries ...testReaderTimelineEntry)
func (*TestReader) Close ¶
func (tr *TestReader) Close() error
type ThreadSafeBuffer ¶ added in v0.22.8
type ThreadSafeBuffer struct {
// contains filtered or unexported fields
}
ThreadSafeBuffer is an io.ReadWriter that is safe for concurrent use by multiple goroutines. It uses an internal bytes.Buffer to store data and a sync.Mutex to ensure thread safety.
func NewThreadSafeBuffer ¶ added in v0.22.8
func NewThreadSafeBuffer() *ThreadSafeBuffer
NewThreadSafeBuffer creates and returns a new ThreadSafeBuffer instance.