fixture

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fixture provides per-subtest builders over the Ella Core client SDK for provisioning scenario fixtures (operator, profiles, slices, data networks, policies, subscribers).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEachBytesIs added in v1.11.0

func AssertEachBytesIs(t *testing.T, flows []client.FlowReport, expected uint64)

AssertEachBytesIs records (t.Errorf, non-fatal) every flow whose Bytes differs from expected, printing the actual value so the constant can be recalibrated from a single run.

func AssertEachTimestampsWithin added in v1.11.0

func AssertEachTimestampsWithin(t *testing.T, flows []client.FlowReport, lower, upper time.Time)

AssertEachTimestampsWithin records (t.Errorf, non-fatal) every flow whose StartTime/EndTime is unparseable, outside [lower, upper], or inverted (EndTime before StartTime).

func AssertFlowReports added in v1.11.0

func AssertFlowReports(
	ctx context.Context,
	t *testing.T,
	c *client.Client,
	params *client.ListFlowReportsParams,
	predicate FlowReportPredicate,
	timeout time.Duration,
) []client.FlowReport

AssertFlowReports polls the flow-reports endpoint with the given filter every 500 ms until predicate returns true or timeout elapses. Returns the snapshot that satisfied predicate; fails the subtest on timeout or API error.

func AssertUsagePositive

func AssertUsagePositive(ctx context.Context, t *testing.T, c *client.Client, imsis []string, timeout time.Duration)

AssertUsagePositive polls Core until uplink and downlink bytes are both > 0 for every IMSI, or the deadline passes. Fails the subtest on timeout.

Types

type DataNetworkSpec

type DataNetworkSpec struct {
	Name     string
	IPv4Pool string
	IPv6Pool string
	DNS      string
	MTU      int32
}

DataNetworkSpec describes a PDU session anchor (DNN + IP pool).

func DefaultDataNetworkSpec

func DefaultDataNetworkSpec() DataNetworkSpec

type F

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

F is a fixture builder bound to one subtest. Methods fail the test via t.Fatalf on API error.

func New

func New(t *testing.T, ctx context.Context, c *client.Client) *F

func (*F) Apply

func (f *F) Apply(spec scenarios.FixtureSpec)

Apply provisions every scenario-owned resource in spec and registers t.Cleanup handlers to delete them when the subtest ends. LIFO cleanup order gives the correct reverse-dependency teardown: subscribers, policies, data networks, slices, profiles.

Scoped resources use strict-create semantics — a name collision fails the test so that stray state from a prior run surfaces immediately instead of silently mutating shared state.

Non-scoped resources (operator singleton, home network keys) are applied idempotently and are not cleaned up; they belong to the baseline shared across all subtests.

Rule for scenario authors: reference baseline names (default profile/slice/DN/policy) only when assertions match baseline values. Anything else must be declared under a scoped name.

func (*F) DataNetwork

func (f *F) DataNetwork(spec DataNetworkSpec)

DataNetwork upserts the baseline data network: when it already exists (e.g. Core's seeded "internet"), its configuration is overwritten to match spec. A pre-existing DN is never left with mismatched parameters; scenarios needing specific DN parameters must use a distinct name.

func (*F) HomeNetworkKey

func (f *F) HomeNetworkKey(spec HomeNetworkKeySpec)

HomeNetworkKey creates a home network key unless the operator already serves one with the matching public key.

func (*F) Operator

func (f *F) Operator(spec OperatorSpec)

Operator writes the operator ID and tracking TACs.

func (*F) OperatorDefault

func (f *F) OperatorDefault()

OperatorDefault writes scenarios-package defaults to the operator.

func (*F) Policy

func (f *F) Policy(spec PolicySpec)

Policy upserts the baseline policy: when it already exists (e.g. Core's seeded "default"), its config is overwritten to match spec.

func (*F) Profile

func (f *F) Profile(spec ProfileSpec)

Profile upserts the baseline profile: when it already exists (e.g. Core's seeded "default"), its UE-AMBR is overwritten to match spec.

func (*F) Slice

func (f *F) Slice(spec SliceSpec)

Slice upserts the baseline slice: when it already exists, its SST/SD are overwritten to match spec.

type FlowReportPredicate added in v1.11.0

type FlowReportPredicate func([]client.FlowReport) bool

FlowReportPredicate evaluates a snapshot of flow reports. Each-prefixed predicates return false on an empty snapshot to avoid vacuous-truth matches during polling.

func And added in v1.11.0

func Count added in v1.11.0

func Count(n int) FlowReportPredicate

func DistinctImsis added in v1.11.0

func DistinctImsis(n int) FlowReportPredicate

func EachAction added in v1.11.0

func EachAction(a string) FlowReportPredicate

func EachBytesAtLeast added in v1.11.0

func EachBytesAtLeast(b uint64) FlowReportPredicate

func EachDestinationIPInCIDR added in v1.11.0

func EachDestinationIPInCIDR(cidr string) FlowReportPredicate

EachDestinationIPInCIDR panics if cidr is malformed.

func EachDestinationIPIs added in v1.11.0

func EachDestinationIPIs(ip string) FlowReportPredicate

func EachDirection added in v1.11.0

func EachDirection(d string) FlowReportPredicate

func EachIMSIDistinctTuplesIs added in v1.11.1

func EachIMSIDistinctTuplesIs(n int) FlowReportPredicate

EachIMSIDistinctTuplesIs requires every distinct IMSI to be associated with exactly n distinct (SourcePort, DestinationPort) tuples — one per connection attempt. Records that share a tuple (e.g. a NetFlow-style split of one connection across multiple observation periods) collapse into the same count.

func EachIMSITotalBytesInRange added in v1.11.1

func EachIMSITotalBytesInRange(lo, hi uint64) FlowReportPredicate

EachIMSITotalBytesInRange requires the sum of Bytes across each distinct IMSI to fall within [lo, hi].

func EachIMSITotalPacketsInRange added in v1.11.1

func EachIMSITotalPacketsInRange(lo, hi uint64) FlowReportPredicate

EachIMSITotalPacketsInRange requires the sum of Packets across each distinct IMSI to fall within [lo, hi].

func EachPackets added in v1.11.0

func EachPackets(n uint64) FlowReportPredicate

func EachProtocol added in v1.11.0

func EachProtocol(p uint8) FlowReportPredicate

func EachSourceIPInCIDR added in v1.11.0

func EachSourceIPInCIDR(cidr string) FlowReportPredicate

EachSourceIPInCIDR panics if cidr is malformed.

func EachSourceIPIs added in v1.11.0

func EachSourceIPIs(ip string) FlowReportPredicate

func EachTupleHasAtMost added in v1.11.1

func EachTupleHasAtMost(n int) FlowReportPredicate

EachTupleHasAtMost requires every distinct (IMSI, SourcePort, DestinationPort) tuple to be backed by at most n flow records. Used to bound NetFlow-style flow-record splitting.

func HasAtLeast added in v1.11.0

func HasAtLeast(n int) FlowReportPredicate

func HasBothDirections added in v1.11.0

func HasBothDirections() FlowReportPredicate

func ImsisAre added in v1.11.0

func ImsisAre(expected []string) FlowReportPredicate

ImsisAre requires the items' SubscriberID multiset to exactly equal expected: each IMSI must appear with the same multiplicity in items as it does in expected, with no extras.

type HomeNetworkKeySpec

type HomeNetworkKeySpec struct {
	KeyIdentifier int
	Scheme        string
	PrivateKey    string
}

HomeNetworkKeySpec carries a hex-encoded X25519 private key and a key identifier.

type OperatorSpec

type OperatorSpec struct {
	MCC           string
	MNC           string
	SupportedTACs []string
}

OperatorSpec captures the singleton operator settings.

type PolicySpec

type PolicySpec struct {
	Name                string
	ProfileName         string
	SliceName           string
	DataNetworkName     string
	SessionAmbrUplink   string
	SessionAmbrDownlink string
	Var5qi              int32
	Arp                 int32
}

PolicySpec describes a QoS policy for a (profile, slice, data network) triple.

func DefaultPolicySpec

func DefaultPolicySpec() PolicySpec

type ProfileSpec

type ProfileSpec struct {
	Name           string
	UeAmbrUplink   string
	UeAmbrDownlink string
}

ProfileSpec describes a subscriber profile (UE-AMBR bucket).

func DefaultProfileSpec

func DefaultProfileSpec() ProfileSpec

type SliceSpec

type SliceSpec struct {
	Name string
	SST  int
	SD   string
}

SliceSpec describes a network slice.

func DefaultSliceSpec

func DefaultSliceSpec() SliceSpec

type SubscriberSpec

type SubscriberSpec struct {
	IMSI           string
	Key            string
	OPc            string
	SequenceNumber string
	ProfileName    string
}

SubscriberSpec describes one subscriber.

Jump to

Keyboard shortcuts

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