utils

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryCount       = 10
	RetryWaitTime    = 5 * time.Second
	RetryMaxWaitTime = 1 * time.Minute
)

Variables

View Source
var (
	MockManagementPlaneAPIAddress          string
	AuxiliaryMockManagementPlaneAPIAddress string
)
View Source
var (
	Container                                 testcontainers.Container
	MockManagementPlaneGrpcContainer          testcontainers.Container
	AuxiliaryMockManagementPlaneGrpcContainer testcontainers.Container
	MockManagementPlaneGrpcAddress            string
	AuxiliaryMockManagementPlaneGrpcAddress   string
)
View Source
var MockCollectorStack *helpers.MockCollectorContainers

Functions

func CheckManifestFile added in v3.3.1

func CheckManifestFile(t *testing.T, container testcontainers.Container,
	expectedContent map[string]*model.ManifestFile,
)

func ClearManagementPlaneResponses

func ClearManagementPlaneResponses(t *testing.T, mockManagementPlaneAPIAddress string)

func CreateContainerNetwork added in v3.3.1

func CreateContainerNetwork(ctx context.Context, tb testing.TB) *testcontainers.DockerNetwork

CreateContainerNetwork creates and configures a container network.

func CurrentFileOverview added in v3.2.0

func CurrentFileOverview(t *testing.T, nginxInstanceID, mockManagementPlaneAPIAddress string) *mpi.FileOverview

func GenerateMetrics added in v3.4.0

func GenerateMetrics(ctx context.Context, t *testing.T, container testcontainers.Container,
	requestCount int, expectedCode string,
)

func ManagementPlaneResponses

func ManagementPlaneResponses(t *testing.T, numberOfExpectedResponses int,
	mockManagementPlaneAPIAddress string,
) []*mpi.DataPlaneResponse

func PerformConfigApply

func PerformConfigApply(t *testing.T, nginxInstanceID, mockManagementPlaneAPIAddress string)

func PerformInvalidConfigApply

func PerformInvalidConfigApply(t *testing.T, nginxInstanceID string)

func PollingForMetrics added in v3.4.0

func PollingForMetrics(t *testing.T, ctx context.Context, metricName string,
	labelFilter LabelFilter, baselineValues []float64,
) []float64

func ScrapeCollectorMetricFamilies added in v3.4.0

func ScrapeCollectorMetricFamilies(t *testing.T, ctx context.Context,
	otelContainer testcontainers.Container,
) map[string]*dto.MetricFamily

func SetupConnectionTest

func SetupConnectionTest(tb testing.TB, expectNoErrorsInLogs, nginxless, auxiliaryServer bool,
	agentConfig string,
) func(tb testing.TB)

func SetupMetricsTest added in v3.4.0

func SetupMetricsTest(tb testing.TB) func(testing.TB)

func SetupMockManagementPlaneGrpc added in v3.3.1

func SetupMockManagementPlaneGrpc(ctx context.Context, tb testing.TB, containerNetwork *testcontainers.DockerNetwork)

SetupMockManagementPlaneGrpc initializes the mock management plane gRPC container.

func SumMetricFamily added in v3.4.0

func SumMetricFamily(metricFamily *dto.MetricFamily) float64

SumMetricFamily retrieves the sum of the metric values in a MetricFamily

func SumMetricFamilyLabel added in v3.4.0

func SumMetricFamilyLabel(metricFamily *dto.MetricFamily, key, val string) float64

SumMetricFamilyLabel retrieves the sum of the metric values for a specific label in a MetricFamily

func VerifyConnection

func VerifyConnection(t *testing.T, instancesLength int, mockManagementPlaneAPIAddress string) string

func VerifyUpdateDataPlaneHealth

func VerifyUpdateDataPlaneHealth(t *testing.T, mockManagementPlaneAPIAddress string)

func VerifyUpdateDataPlaneStatus

func VerifyUpdateDataPlaneStatus(t *testing.T, mockManagementPlaneAPIAddress string)

func WaitForMetricsToExist added in v3.4.0

func WaitForMetricsToExist(t *testing.T, ctx context.Context)

func WaitUntilNextScrapeCycle added in v3.4.0

func WaitUntilNextScrapeCycle(t *testing.T, ctx context.Context)

func WriteConfigFileDataplane added in v3.3.1

func WriteConfigFileDataplane(t *testing.T, file1, file2, file3 string)

func WriteConfigFileMock added in v3.3.1

func WriteConfigFileMock(t *testing.T, nginxInstanceID, file1, file2, file3 string)

Types

type ConnectionRequest

type ConnectionRequest struct {
	ConnectionRequest *mpi.CreateConnectionRequest `json:"connectionRequest"`
}

type Instance

type Instance struct {
	InstanceMeta    *mpi.InstanceMeta    `json:"instance_meta"`
	InstanceRuntime *mpi.InstanceRuntime `json:"instance_runtime"`
}

type LabelFilter added in v3.4.0

type LabelFilter struct {
	Key    string
	Values []string
}

type NginxUpdateDataPlaneHealthRequest

type NginxUpdateDataPlaneHealthRequest struct {
	MessageMeta *mpi.MessageMeta `json:"message_meta"`
	Instances   []Instance       `json:"instances"`
}

type UpdateDataPlaneStatusRequest

type UpdateDataPlaneStatusRequest struct {
	UpdateDataPlaneStatusRequest NginxUpdateDataPlaneHealthRequest `json:"updateDataPlaneStatusRequest"`
}

Jump to

Keyboard shortcuts

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