Skip to content

Commit

Permalink
e2e: add testcase for proxy redirect crash after quota exhaustion
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Matov authored and ivan4th committed Jun 6, 2022
1 parent 1312ba4 commit f4a6aa3
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/e2e/framework/sessionconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type SessionConfig struct {
MonitoringTime time.Time
VTime time.Duration
MeasurementPeriod time.Duration
VolumeQuota uint32
ForwardingPolicyID string
NatPoolName string
IMSI string
Expand Down Expand Up @@ -335,14 +336,35 @@ func (cfg SessionConfig) CreateOrUpdateURR(id uint32, update bool) *ie.IE {
return urr
}

func (cfg SessionConfig) CreateVolumeURR(id uint32) *ie.IE {
triggers := uint16(0)
triggers |= pfcp.ReportingTriggers_VOLQU
urr := ie.NewCreateURR(ie.NewURRID(id),
ie.NewMeasurementMethod(0, 1, 1),
ie.NewVolumeQuota(0x01, 1024, 0, 0),
ie.NewReportingTriggers(triggers))
return urr
}

func (cfg SessionConfig) DeleteURR(id uint32) *ie.IE {
return ie.NewRemoveURR(ie.NewURRID(id))
}

func (cfg SessionConfig) CreateURRs() []*ie.IE {
if cfg.VolumeQuota != 0 {
return []*ie.IE{cfg.CreateVolumeURR(1), cfg.CreateVolumeURR(2)}
}
return []*ie.IE{cfg.CreateOrUpdateURR(1, false), cfg.CreateOrUpdateURR(2, false)}
}

func (cfg SessionConfig) UpdateURRs() []*ie.IE {
return []*ie.IE{cfg.CreateOrUpdateURR(1, true), cfg.CreateOrUpdateURR(2, true)}
}

func (cfg SessionConfig) DeleteURRs() []*ie.IE {
return []*ie.IE{cfg.DeleteURR(1), cfg.DeleteURR(2)}
}

func (cfg SessionConfig) SessionIEs() []*ie.IE {
ies := cfg.CreateFARs()
if !cfg.NoURRs {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/pfcp/pfcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const (

ReportingTriggers_QUVTI = 0x0080 // Quota Validity Time
ReportingTriggers_PERIO = 0x0100 // Periodic Reporting
ReportingTriggers_VOLQU = 0x0001 // Volume Quota

maxRequestAttempts = 10

Expand Down
62 changes: 62 additions & 0 deletions test/e2e/upg_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,68 @@ var _ = ginkgo.Describe("[Reporting]", func() {
verifyNoSession(f, seid)
})
})

ginkgo.Context("Quota", func() {
f := framework.NewDefaultFramework(framework.UPGModeTDF, framework.UPGIPModeV4)
ginkgo.It("should not cause problems after adding a redirect after exhaustion [NAT]", func() {
ginkgo.By("Creating session with volume quota")
setupNAT(f)
sessionCfg := &framework.SessionConfig{
IdBase: 1,
UEIP: f.UEIP(),
Mode: f.Mode,
VolumeQuota: 1024,
// request a report _after_ the monitoring time
}
sessionCfg.NatPoolName = "testing"
reportCh := f.PFCP.AcquireReportCh()
seid, err := f.PFCP.EstablishSession(f.Context, 0, sessionCfg.SessionIEs()...)
framework.ExpectNoError(err)

out, err := f.VPP.Ctl("show upf session")
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(string(out)).To(gomega.ContainSubstring("1024"))

ginkgo.By("Starting some traffic")
tg, clientNS, serverNS := newTrafficGen(f, &traffic.HTTPConfig{
ChunkCount: 380, // 18s
Retry: true,
ChunkDelay: 100 * time.Millisecond,
}, &traffic.SimpleTrafficRec{})
tg.Start(f.Context, clientNS, serverNS)

ginkgo.By("Expecting report to be happen due to Volume Quota Exhausted")
var msg message.Message
gomega.Eventually(reportCh, 20*time.Second, 50*time.Millisecond).Should(gomega.Receive(&msg))
_, err = pfcp.GetMeasurement(msg)
framework.ExpectNoError(err, "GetMeasurement")

ginkgo.By("Updating session by removing FARs/PDRs/URRs for forwarding")
modifyIEs := sessionCfg.DeletePDRs()
modifyIEs = append(modifyIEs, sessionCfg.DeleteFARs()...)
modifyIEs = append(modifyIEs, sessionCfg.DeleteURRs()...)
_, err = f.PFCP.ModifySession(
f.VPP.Context(context.Background()), seid,
modifyIEs...)
framework.ExpectNoError(err, "ModifySession")
out, err = f.VPP.Ctl("show upf session")
gomega.Expect(err).NotTo(gomega.HaveOccurred())

sessionCfg.NoURRs = true
sessionCfg.Redirect = true
modifyIEs = sessionCfg.CreatePDRs()
modifyIEs = append(modifyIEs, sessionCfg.CreateFARs()...)
_, err = f.PFCP.ModifySession(f.VPP.Context(context.Background()), seid, modifyIEs...)
framework.ExpectNoError(err, "ModifySession")
time.Sleep(time.Second * 5)

ginkgo.By("Verifying redirects...")
runTrafficGen(f, &traffic.RedirectConfig{
RedirectLocationSubstr: "127.0.0.1/this-is-my-redirect",
RedirectResponseSubstr: "<title>Redirection</title>",
}, &traffic.PreciseTrafficRec{})
})
})
})

const leakTestNumSessions = 10000
Expand Down

0 comments on commit f4a6aa3

Please sign in to comment.