Skip to content

Commit

Permalink
Add e2e test case for UP-dropped session w/o URRs
Browse files Browse the repository at this point in the history
Check the UISR bit
  • Loading branch information
ivan4th committed Jun 7, 2021
1 parent 006b3f2 commit 1f04742
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 13 deletions.
34 changes: 22 additions & 12 deletions test/e2e/framework/sessionconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type SessionConfig struct {
ProxyCoreIP net.IP
ProxyAccessTEID uint32
ProxyCoreTEID uint32
NoURRs bool
}

const (
Expand Down Expand Up @@ -226,28 +227,37 @@ func (cfg SessionConfig) SessionIEs() []*ie.IE {
ies := []*ie.IE{
cfg.forwardFAR(1),
cfg.reverseFAR(2),
ie.NewCreateURR(
ie.NewURRID(1),
ie.NewMeasurementMethod(0, 1, 1), // VOLUM=1 DURAT=1
ie.NewReportingTriggers(0)),
ie.NewCreateURR(
ie.NewURRID(2),
ie.NewMeasurementMethod(0, 1, 1), // VOLUM=1 DURAT=1
ie.NewReportingTriggers(0)),
}
if !cfg.NoURRs {
ies = append(ies,
ie.NewCreateURR(
ie.NewURRID(1),
ie.NewMeasurementMethod(0, 1, 1), // VOLUM=1 DURAT=1
ie.NewReportingTriggers(0)),
ie.NewCreateURR(
ie.NewURRID(2),
ie.NewMeasurementMethod(0, 1, 1), // VOLUM=1 DURAT=1
ie.NewReportingTriggers(0)))
}

return append(ies, cfg.CreatePDRs()...)
}

func (cfg SessionConfig) CreatePDRs() []*ie.IE {
defaultURRId := uint32(1)
appURRId := uint32(2)
if cfg.NoURRs {
defaultURRId = 0
appURRId = 0
}
ies := []*ie.IE{
cfg.forwardPDR(cfg.IdBase, 1, 1, 200, ""),
cfg.reversePDR(cfg.IdBase+1, 2, 1, 200, ""),
cfg.forwardPDR(cfg.IdBase, 1, defaultURRId, 200, ""),
cfg.reversePDR(cfg.IdBase+1, 2, defaultURRId, 200, ""),
}
if cfg.AppName != "" {
ies = append(ies,
cfg.forwardPDR(cfg.IdBase+2, 1, 2, 100, cfg.AppName),
cfg.reversePDR(cfg.IdBase+3, 2, 2, 100, cfg.AppName))
cfg.forwardPDR(cfg.IdBase+2, 1, appURRId, 100, cfg.AppName),
cfg.reversePDR(cfg.IdBase+3, 2, appURRId, 100, cfg.AppName))
}
return ies
}
Expand Down
49 changes: 48 additions & 1 deletion test/e2e/upg_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ var _ = ginkgo.Describe("Multiple PFCP Sessions", func() {
"session-related memory leak detected")
})

ginkgo.It("should not be allowed to conflict on UE IPs", func() {
ginkgo.It("should not be allowed to conflict on UE IPs and drop the older conflicting session", func() {
sessionCfg := &framework.SessionConfig{
IdBase: 1,
UEIP: f.UEIP(),
Expand Down Expand Up @@ -642,6 +642,53 @@ var _ = ginkgo.Describe("Multiple PFCP Sessions", func() {
verifyNoSession(f, newSEID)
})

ginkgo.It("should not be allowed to conflict on UE IPs and drop the older conflicting session [no URRs]", func() {
sessionCfg := &framework.SessionConfig{
IdBase: 1,
UEIP: f.UEIP(),
Mode: f.Mode,
NoURRs: true,
}
reportCh := f.PFCP.AcquireReportCh()
seid, err := f.PFCP.EstablishSession(f.Context, 0, sessionCfg.SessionIEs()...)
framework.ExpectNoError(err)

var newSEID pfcp.SEID
newSEID = f.PFCP.NewSEID()
_, err = f.PFCP.EstablishSession(f.Context, newSEID, sessionCfg.SessionIEs()...)
framework.ExpectError(err)

var serverErr *pfcp.PFCPServerError
gomega.Expect(errors.As(err, &serverErr)).To(gomega.BeTrue())
framework.ExpectEqual(newSEID, serverErr.SEID)
framework.ExpectEqual(serverErr.Cause, ie.CauseRuleCreationModificationFailure)
framework.Logf("Server error (expected): %v", err)

var m message.Message
gomega.Eventually(reportCh, 10*time.Second, 50*time.Millisecond).Should(gomega.Receive(&m))
framework.ExpectEqual(m.MessageType(), message.MsgTypeSessionReportRequest)

rr := m.(*message.SessionReportRequest)
gomega.Expect(rr.ReportType).NotTo(gomega.BeNil())
_, err = rr.ReportType.ReportType()
framework.ExpectNoError(err)
gomega.Expect(rr.ReportType.HasUPIR()).To(gomega.BeFalse())
gomega.Expect(rr.ReportType.HasERIR()).To(gomega.BeFalse())
gomega.Expect(rr.ReportType.HasUSAR()).To(gomega.BeFalse())
gomega.Expect(rr.ReportType.HasDLDR()).To(gomega.BeFalse())
// FIXME: UISR bit is not yet handled by go-pfcp
rt, _ := rr.ReportType.ReportType()
gomega.Expect(rt & 0x40).NotTo(gomega.BeZero())

gomega.Expect(rr.PFCPSRReqFlags).NotTo(gomega.BeNil())
gomega.Expect(rr.PFCPSRReqFlags.HasPSDBU()).To(gomega.BeTrue())

gomega.Expect(rr.UsageReport).To(gomega.HaveLen(0))

verifyNoSession(f, seid)
verifyNoSession(f, newSEID)
})

ginkgo.It("should not be allowed to conflict on SEIDs", func() {
sessionCfg := &framework.SessionConfig{
IdBase: 1,
Expand Down

0 comments on commit 1f04742

Please sign in to comment.