testutil

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentSpecHash added in v0.0.4

func CurrentSpecHash() string

CurrentSpecHash returns a stable hash for the currently running Ginkgo spec.

func DumpNamespaceDiagnostics added in v0.0.4

func DumpNamespaceDiagnostics(ctx context.Context, config *rest.Config, cli client.Client, ns, dir string)

DumpNamespaceDiagnostics dumps resources, pod logs and events from namespace.

func DumpNamespaceEvents added in v0.0.4

func DumpNamespaceEvents(ctx context.Context, cli client.Client, namespace string, since time.Time) (string, error)

DumpNamespaceEvents fetches all events in the namespace that occurred since sinceTime.

func EnsureNamespace added in v0.0.4

func EnsureNamespace(ctx context.Context, k8sClient client.Client, name string)

EnsureNamespace ensures the test namespace is created and active.

func GetProjectDir

func GetProjectDir() (string, error)

GetProjectDir will return the directory where the project is by walking up from the current working directory until it finds a go.mod file.

func InstallCRDs added in v0.0.4

func InstallCRDs(ctx context.Context) error

InstallCRDs installs the CRDs into the cluster using make install.

func InstallCertManager

func InstallCertManager(ctx context.Context) error

InstallCertManager installs the cert manager bundle.

func NewPortForwardDialer added in v0.0.4

func NewPortForwardDialer(config *rest.Config) controllerutil.DialContextFunc

NewPortForwardDialer returns a DialContextFunc that connects to pods inside a Kubernetes cluster by creating SPDY port-forward streams through the API server. Pod hostnames are expected in the format: {podName}.{serviceName}.{namespace}.svc.{domain}.

func PreloadImages added in v0.0.4

func PreloadImages(ctx context.Context, images []string) *errgroup.Group

PreloadImages pulls each image from the registry and loads it into the kind cluster. All images are processed in parallel.

func Run

func Run(cmd *exec.Cmd) ([]byte, error)

Run executes the provided command within this context.

func SetupCA

func SetupCA(ctx context.Context, k8sClient client.Client, namespace string, suffix uint32)

SetupCA sets up a self-signed CA issuer and a CA certificate in the given namespace.

func UninstallCRDs added in v0.0.4

func UninstallCRDs(ctx context.Context) error

UninstallCRDs removes the CRDs from the cluster using make uninstall.

Types

type ClickHouseClient

type ClickHouseClient struct {
	// contains filtered or unexported fields
}

ClickHouseClient is a ClickHouse client for testing ClickHouse clusters.

func NewClickHouseClient

func NewClickHouseClient(
	ctx context.Context,
	dialer controllerutil.DialContextFunc,
	cr *v1.ClickHouseCluster,
	auth ...clickhouse.Auth,
) (*ClickHouseClient, error)

NewClickHouseClient creates a new ClickHouseClient connected to the specified ClickHouseCluster.

func (*ClickHouseClient) CheckDefaultDatabasesReplicated

func (c *ClickHouseClient) CheckDefaultDatabasesReplicated(ctx context.Context) error

CheckDefaultDatabasesReplicated checks that the default database has Replicated engine on all cluster nodes.

func (*ClickHouseClient) CheckRead

func (c *ClickHouseClient) CheckRead(ctx context.Context, order int) error

CheckRead reads and verifies test data from the ClickHouse cluster.

func (*ClickHouseClient) CheckWrite

func (c *ClickHouseClient) CheckWrite(ctx context.Context, order int) error

CheckWrite writes test data to the ClickHouse cluster.

func (*ClickHouseClient) Close

func (c *ClickHouseClient) Close()

Close closes the ClickHouseClient and releases all resources.

func (*ClickHouseClient) CreateDatabase

func (c *ClickHouseClient) CreateDatabase(ctx context.Context) error

CreateDatabase creates the test database on the ClickHouse cluster.

func (*ClickHouseClient) Exec added in v0.0.3

func (c *ClickHouseClient) Exec(ctx context.Context, query string, args ...any) error

Exec executes a query on one of the ClickHouse cluster nodes.

func (*ClickHouseClient) Query added in v0.0.3

func (c *ClickHouseClient) Query(ctx context.Context, query string, args ...any) (driver.Rows, error)

Query executes a query on one of the ClickHouse cluster nodes.

func (*ClickHouseClient) QueryRow

func (c *ClickHouseClient) QueryRow(ctx context.Context, query string, result any) error

QueryRow executes a query on one of the ClickHouse cluster nodes. Scans the result into the provided result variable.

type DumpResult added in v0.0.4

type DumpResult struct {
	Short string
	Full  string
}

DumpResult holds a short summary and the full dump content.

func DumpNamespacePodLogs added in v0.0.4

func DumpNamespacePodLogs(ctx context.Context, config *rest.Config, namespace string) (DumpResult, error)

DumpNamespacePodLogs collects logs for all pod containers in the given namespace. The short dump contains only the last logTailLines lines per container.

func DumpNamespaceResources added in v0.0.4

func DumpNamespaceResources(ctx context.Context, cli client.Client, namespace string) (DumpResult, error)

DumpNamespaceResources collects all resources in the namespace. The full dump contains the complete JSON representation of each resource, while the short dump contains only the resource type and object names.

func (*DumpResult) Empty added in v0.0.4

func (d *DumpResult) Empty() bool

Empty returns true if no data dumped.

func (*DumpResult) WriteFull added in v0.0.4

func (d *DumpResult) WriteFull(dir, filename string) (string, error)

WriteFull writes the full dump to a file inside dir and returns the file path.

type KeeperClient

type KeeperClient struct {
	// contains filtered or unexported fields
}

KeeperClient is a ZooKeeper client for testing Keeper clusters.

func NewKeeperClient

func NewKeeperClient(
	ctx context.Context, dialer controllerutil.DialContextFunc, cr *v1.KeeperCluster,
) (*KeeperClient, error)

NewKeeperClient creates a new KeeperClient connected to the specified KeeperCluster.

func (*KeeperClient) CheckRead

func (c *KeeperClient) CheckRead(order int) error

CheckRead reads and verifies test data from the Keeper cluster.

func (*KeeperClient) CheckWrite

func (c *KeeperClient) CheckWrite(order int) error

CheckWrite writes test data to the Keeper cluster.

func (*KeeperClient) Close

func (c *KeeperClient) Close()

Close closes the KeeperClient and releases all resources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL