integration

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 40 Imported by: 0

README


id: readme_cwag_integ_test title: CWAG Integration Test hide_title: true

Integration Test Setup

This integration currently uses 3 separate VMs to run the tests: cwag-test and cwag-dev in magma/cwf/gateway, and magma-trfserver in magma/modules/lte/gateway. The fabfile in this directory can be used to automate the setup needed to run the test.

cwag-dev

This VM will build and run all cwag services and mock core services needed to run the test. See the various docker-compose files in cwf/gateway/docker to see the complete list of services.

cwag-test

This VM will be used to run the tests. We will also run a UE simulator service to simulate a UE device in the test.

magma-trfserver

This VM runs an iperf3 server.

TestSetup

Current Tests

  • UE Authentication
  • Basic Traffic test with pass all policies
  • Gx Credit Control Request/Answer flow for Init/Update/Terminate
  • Gx ReAuth Request/Answer flow
  • Gx rule enforcement
    • Static and dynamic rules
    • Rule base mappings
    • Omnipresent (Network wide rules)
    • Rule activation/deactivation time
  • Gx usage monitor installation/enforcement
  • Gx Abort Session Request/Answer flow
  • Gx QoS downgrade and negotiation
  • Gy ReAuth Request/Answer flow
  • Gy Final-Unit-Action-Terminate enforcement

Running the test

Requirements

To the run the test, run fab integ_test from magma/cwf/gateway. This fabfile will

  • Provision the 3 VMs
  • Build and start docker containers on cwag-dev
  • Start the UE simulator service on cwag-test
  • Start the iperf3 server on magma-trfserver
  • Run the integration test on cwag-test
  • Clean up (Kill the UE sim on cwag-test and stop the iperf3 server on magma-trfserver)
Fab script parameters
  • no_build: The fabfile by default stops, rebuilds, and starts all containers. If you only want to restart the containers, and not rebuild everything, run fab integ_test:no_build=True.
  • tests_to_run: By default, the fab script will run all existing tests. You can specify a subset of them with this flag. For example, run fab integ_test:tests_to_run=gx, to only run Gx tests. See the fabfile for more options.

Debugging on cwag-dev VM

  • To see the list of running services, run docker ps in the cwag-dev VM.
  • To see per-service logs, run docker-compose logs <container_name>
  • To go into a running container, run docker-compose exec <container_name> bash
  • /usr/local/bin/pipelined_cli.py in pipelined service maybe useful for viewing installed flows for debugging.

Before you commit any code...

Before committing, please make sure you run the commands below to test and format.

  • If you touch anything in magma/cwf/gateway, run make precommit on the cwag-dev VM, under magma/cwf/gateway.
  • If you touch anything in magma/feg/gateway, run make precommit inside the FeG test container.
    • cd magma/feg/gateway/docker
    • docker-compose up -d test
    • docker-compose exec test /bin/bash
    • make precommit
  • If you touch anything in magma/.../cloud/go, please run the orc8r precommit.
    • cd magma/orc8r/cloud/go/docker
    • ./build.py -m
    • make precommit

Additionally, if you write any new tests, please summarize what the test does in a comment above the test. See existing tests for example.

FAQ

Unit tests are not able to run: /cwf/gateway: No such file or directory

→ The cwag-dev VM probably did not provision properly. Run vagrant provision cwag in magma/cwf/gateway to provision the VM again to see specific errors.

Docker is failing to build due to lack of space

→ Since docker does not garbage collect previously built images, we will have to manually prune them. Run docker system df to see memory usage and what can be deleted. To remove these images, run docker image prune --filter until=12h.

All traffic hang and then fail

→ This is an issue we've observed occasionally. We have not found the root cause yet. Assuming the issue is not with the CWAG services, one remedy you can try is to destroy all VMs and start them again.

Documentation

Index

Constants

View Source
const (
	Op               = "\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
	Secret           = "123456"
	MockHSSRemote    = "HSS_REMOTE"
	MockPCRFRemote   = "PCRF_REMOTE"
	MockOCSRemote    = "OCS_REMOTE"
	MockPCRFRemote2  = "PCRF_REMOTE2"
	MockOCSRemote2   = "OCS_REMOTE2"
	PipelinedRemote  = "pipelined.local"
	DirectorydRemote = "DIRECTORYD"
	RedisRemote      = "REDIS"
	CwagIP           = "192.168.70.101"
	TrafficCltIP     = "192.168.128.2"
	IPDRControllerIP = "192.168.40.11"
	OCSPort          = 9201
	PCRFPort         = 9202
	OCSPort2         = 9205
	PCRFPort2        = 9206
	HSSPort          = 9204
	PipelinedPort    = 8443
	RedisPort        = 6380
	DirectorydPort   = 8443

	KiloBytes                = 1024
	MegaBytes                = 1024 * KiloBytes
	Buffer                   = 100 * KiloBytes
	RevalidationTimeoutEvent = 17

	ReAuthMaxUsageBytes   = 5 * MegaBytes
	ReAuthMaxUsageTimeSec = 1000 // in second
	ReAuthValidityTime    = 60   // in second

	GyMaxUsageBytes = 5 * MegaBytes
	GyMaxUsageTime  = 1000 // in second
	GyValidityTime  = 60   // in second
)

todo make Op configurable, or export it in the UESimServer.

Variables

View Source
var (
	// PCRFinstances List of all possible PCRFs on the system (currently 2 are supported)
	PCRFinstances = []string{MockPCRFRemote, MockPCRFRemote2}
	// OCSinstances List of all possible OCSs on the system (currently 2 are supported)
	OCSinstances = []string{MockOCSRemote, MockOCSRemote2}
)

Functions

This section is empty.

Types

type CmdOutput

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

CmdOutput struct representing output of docker container command

type RecordByIMSI

type RecordByIMSI map[string]map[string]*lteprotos.RuleRecord

imsi -> ruleID -> record

type RuleManager

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

RuleManager keeps track of rules and monitors for the integration test. It keeps track of all successfully installed static/dynamic rules along with usage monitors. The dynamic rules and usage monitors are added into the mock PCRF service. The static rules are usually streamed down into gateway policyDB from the cloud. Since this integration test does not cover the cloud component, we will directly insert the static policies into the redis database by using policyDBWrapper.

func NewRuleManager

func NewRuleManager() (*RuleManager, error)

NewRuleManager initialized the struct

func NewRuleManagerPerInstance

func NewRuleManagerPerInstance(pcrfInstance string) (*RuleManager, error)

NewRuleManagerPerInstance initialized the struct per PCRFinstance

func (*RuleManager) AddBaseNameMappingToDB

func (manager *RuleManager) AddBaseNameMappingToDB(basename string, ruleNames []string) error

func (*RuleManager) AddDynamicPassAllToPCRF

func (manager *RuleManager) AddDynamicPassAllToPCRF(imsi, ruleID, monitoringKey string) error

AddDynamicPassAllToPCRF adds a dynamic rule that passes all traffic into PCRF

func (*RuleManager) AddOmniPresentRulesToDB

func (manager *RuleManager) AddOmniPresentRulesToDB(keyId string, ruleNames, baseNames []string) error

AddOmniPresentRulesToDB adds the network wide static rule to policyDB storage

func (*RuleManager) AddRulesToPCRF

func (manager *RuleManager) AddRulesToPCRF(imsi string, ruleNames, baseNames []string) error

AddRulesToPCRF adds the dynamic rule into PCRF

func (*RuleManager) AddStaticPassAllToDB

func (manager *RuleManager) AddStaticPassAllToDB(ruleID string, monitoringKey string, ratingGroup uint32, trackingType string, priority uint32) error

AddStaticPassAllToDB adds a static rule that passes all traffic to policyDB storage

func (*RuleManager) AddStaticPassAllToDBAndPCRFforIMSIs

func (manager *RuleManager) AddStaticPassAllToDBAndPCRFforIMSIs(IMSIs []string, ruleID string, monitoringKey string, ratingGroup uint32, trackingType string, priority uint32) error

AddStaticPassAllToDBAndPCRF adds a static rule that passes all traffic to policyDB storage and to the PCRF instance

func (*RuleManager) AddStaticRuleToDB

func (manager *RuleManager) AddStaticRuleToDB(rule *lteProtos.PolicyRule) error

AddStaticRuleToDB adds the static rule to policyDB storage

func (*RuleManager) AddUsageMonitor

func (manager *RuleManager) AddUsageMonitor(imsi, monitoringKey string, volume, bytesPerGrant uint64) error

AddUsageMonitor constructs a usage monitor according to the parameters and inserts it into PCRF

func (*RuleManager) GetInstalledRulesByIMSI

func (manager *RuleManager) GetInstalledRulesByIMSI() map[string][]string

GetInstalledRulesByIMSI returns all dynamic rule ids and static rules referenced by dynamic rules keyed by the IMSI they are attached to.

func (*RuleManager) RemoveInstalledRules

func (manager *RuleManager) RemoveInstalledRules() error

RemoveInstalledRules removes previously installed rules from PCRF and policyDB

func (*RuleManager) RemoveOmniPresentRulesFromDB

func (manager *RuleManager) RemoveOmniPresentRulesFromDB(keyId string) error

RemoveOmniPresentRulesFromDB adds the network wide static rule to policyDB storage

type TestRunner

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

TestRunner helps setting up all associated services

func NewTestRunner

func NewTestRunner(t *testing.T) *TestRunner

NewTestRunner initializes a new TestRunner by making a UESim client and and setting the next IMSI.

func NewTestRunnerWithTwoPCRFandOCS

func NewTestRunnerWithTwoPCRFandOCS(t *testing.T) *TestRunner

NewTestRunnerWithTwoPCRFandOCS does the same as NewTestRunner but it inclides 2 PCRF and 2 OCS Used in scenarios that run 2 PCRFs and 2 OCSs

func (*TestRunner) AssertAllGxExpectationsMetNoError

func (tr *TestRunner) AssertAllGxExpectationsMetNoError()

Query assertion result from MockPCRF and assert all expectations were met. Only applicable when MockDriver is used.

func (*TestRunner) AssertAllGyExpectationsMetNoError

func (tr *TestRunner) AssertAllGyExpectationsMetNoError()

Query assertion result from MockOCS and assert all expectations were met. Only applicable when MockDriver is used.

func (*TestRunner) AssertPolicyEnforcementRecordIsNil

func (tr *TestRunner) AssertPolicyEnforcementRecordIsNil(imsi string)

Query policy usage records from pipelined, and assert that there is no entry for the IMSI. This means no policy flows are installed for the IMSI.

func (*TestRunner) Authenticate

func (tr *TestRunner) Authenticate(imsi, calledStationID string) (*radius.Packet, error)

Authenticate simulates an authentication between the UE and the HSS with the specified IMSI and CalledStationID, and returns the resulting Radius packet.

func (*TestRunner) AuthenticateAndAssertFail

func (tr *TestRunner) AuthenticateAndAssertFail(imsi string)

Trigger a UE Authentication with the IMSI. Assert that the authentication failed.

func (*TestRunner) AuthenticateAndAssertSuccess

func (tr *TestRunner) AuthenticateAndAssertSuccess(imsi string)

Trigger a UE Authentication with the IMSI. Assert that the authentication succeeded.

func (*TestRunner) AuthenticateAndAssertSuccessWithRetries

func (tr *TestRunner) AuthenticateAndAssertSuccessWithRetries(imsi string, maxRetries int)

AuthenticateAndAssertSuccessWithRetries triggers a UE Authentication with the IMSI. Assert that the authentication succeeded with retrials. Use this function only for those tests that deal with service restart Otherwise, use the client without retries. Retries shuldn't happen on a healthy system

func (*TestRunner) AuthenticateWithCalledIDAndAssertSuccess

func (tr *TestRunner) AuthenticateWithCalledIDAndAssertSuccess(imsi, calledStationID string)

Trigger a UE Authentication with the IMSI and called station ID. Assert that the authentication succeeded.

func (*TestRunner) CleanUp

func (tr *TestRunner) CleanUp() error

Remove subscribers, rules, flows, and monitors to clean up the state for consecutive test runs

func (*TestRunner) ConfigUEs

func (tr *TestRunner) ConfigUEs(numUEs int) ([]*cwfprotos.UEConfig, error)

ConfigUEs creates and adds the specified number of UEs and Subscribers to the UE Simulator and the HSS.

func (*TestRunner) ConfigUEsPerInstance

func (tr *TestRunner) ConfigUEsPerInstance(IMSIs []string, pcrfInstance, ocsInstance string) ([]*cwfprotos.UEConfig, error)

ConfigUEsPerInstance same as ConfigUEs but per specific PCRF and OCS instance

func (*TestRunner) Disconnect

func (tr *TestRunner) Disconnect(imsi, calledStationID string) (*radius.Packet, error)

Authenticate simulates an authentication between the UE and the HSS with the specified IMSI and CalledStationID, and returns the resulting Radius packet.

func (*TestRunner) DisconnectAndAssertSuccess

func (tr *TestRunner) DisconnectAndAssertSuccess(imsi string)

Trigger a UE Disconnect and assert it succeeds.

func (*TestRunner) GenULTraffic

GenULTraffic simulates the UE sending traffic through the CWAG to the Internet by running an iperf3 client on the UE simulator and an iperf3 server on the Magma traffic server.

func (*TestRunner) GetPolicyUsage

func (tr *TestRunner) GetPolicyUsage() (RecordByIMSI, error)

GetPolicyUsage is a wrapper around pipelined's GetPolicyUsage and returns the policy usage keyed by subscriber ID

func (*TestRunner) OverwriteMConfig

func (tr *TestRunner) OverwriteMConfig(mconfigPath string, serviceName string) error

OverwriteMConfig adds ability to overwrite the mconfig file with a specified file

func (*TestRunner) PauseService

func (tr *TestRunner) PauseService(serviceName string) error

StopService adds ability to stop a particular service managed by docker

func (*TestRunner) RestartService

func (tr *TestRunner) RestartService(serviceName string) error

RestartService adds ability to restart a particular service managed by docker

func (*TestRunner) RunCommandInContainer

func (tr *TestRunner) RunCommandInContainer(serviceName string, cmdList [][]string) ([]*CmdOutput, error)

RunCommandInContainer adds ability to run a specific command within a container

func (*TestRunner) ScanContainerLogs

func (tr *TestRunner) ScanContainerLogs(serviceName string, line string) int

ScanContainerLogs provides ability to scan the container logs for a string

func (*TestRunner) WaitForEnforcementStatsToSync

func (tr *TestRunner) WaitForEnforcementStatsToSync()

func (*TestRunner) WaitForPoliciesToSync

func (tr *TestRunner) WaitForPoliciesToSync()

func (*TestRunner) WaitForReAuthToProcess

func (tr *TestRunner) WaitForReAuthToProcess()

Jump to

Keyboard shortcuts

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