diff --git a/test/integration/conf.go b/test/integration/conf.go index cf28cae2d..f054c93ef 100644 --- a/test/integration/conf.go +++ b/test/integration/conf.go @@ -15,6 +15,11 @@ const ( ConfigUPFBasedIPAllocation ) +const ( + UEPoolUPF = "10.250.0.0/16" + UEPoolCP = "17.0.0.0/16" +) + var baseConfig = pfcpiface.Conf{ ReadTimeout: 15, RespTimeout: "2s", @@ -45,7 +50,7 @@ func BESSConfigUPFBasedIPAllocation() pfcpiface.Conf { config := BESSConfigDefault() config.CPIface = pfcpiface.CPIfaceInfo{ EnableUeIPAlloc: true, - UEIPPool: "10.250.0.0/16", + UEIPPool: UEPoolUPF, } return config @@ -73,7 +78,7 @@ func UP4ConfigDefault() pfcpiface.Conf { } config.CPIface = pfcpiface.CPIfaceInfo{ - UEIPPool: "10.250.0.0/16", + UEIPPool: UEPoolCP, } return config @@ -83,7 +88,7 @@ func UP4ConfigUPFBasedIPAllocation() pfcpiface.Conf { config := UP4ConfigDefault() config.CPIface = pfcpiface.CPIfaceInfo{ EnableUeIPAlloc: true, - UEIPPool: "10.250.0.0/16", + UEIPPool: UEPoolUPF, } return config diff --git a/test/integration/verify.go b/test/integration/verify.go index 1346957f7..541577146 100644 --- a/test/integration/verify.go +++ b/test/integration/verify.go @@ -7,6 +7,7 @@ import ( "fmt" p4rtc "github.com/antoninbas/p4runtime-go-client/pkg/client" "github.com/antoninbas/p4runtime-go-client/pkg/util/conversion" + "github.com/omec-project/upf-epc/internal/p4constants" "github.com/omec-project/upf-epc/test/integration/providers" p4_v1 "github.com/p4lang/p4runtime/go/p4/v1" "github.com/stretchr/testify/require" @@ -37,6 +38,43 @@ const ( ActDownlinkTermFwdNoTC = "PreQosPipe.downlink_term_fwd_no_tc" ) +var ( + tablesNames = p4constants.GetTableIDToNameMap() + actionNames = p4constants.GetActionIDToNameMap() +) + +func buildExpectedInterfacesEntries(client *p4rtc.Client, testdata *pfcpSessionData, expectedValues p4RtValues) []*p4_v1.TableEntry { + entries := make([]*p4_v1.TableEntry, 0, 2) + + n3Addr, _ := conversion.IpToBinary(testdata.upfN3Address) + + te := client.NewTableEntry(tablesNames[p4constants.TablePreQosPipeInterfaces], []p4rtc.MatchInterface{ + &p4rtc.LpmMatch{ + Value: n3Addr, + PLen: 32, + }, + }, client.NewTableActionDirect(actionNames[p4constants.ActionPreQosPipeSetSourceIface], + [][]byte{{directionUplink}, {srcIfaceAccess}, {testdata.sliceID}}), + nil) + + entries = append(entries, te) + + ueAddr, _ := conversion.IpToBinary(expectedValues.ueAddress) + + te = client.NewTableEntry(tablesNames[p4constants.TablePreQosPipeInterfaces], []p4rtc.MatchInterface{ + &p4rtc.LpmMatch{ + Value: ueAddr, + PLen: 16, + }, + }, client.NewTableActionDirect(actionNames[p4constants.ActionPreQosPipeSetSourceIface], + [][]byte{{directionDownlink}, {srcIfaceCore}, {testdata.sliceID}}), + nil) + + entries = append(entries, te) + + return entries +} + func buildExpectedApplicationsEntry(client *p4rtc.Client, testdata *pfcpSessionData, expectedValues p4RtValues) *p4_v1.TableEntry { if expectedValues.appFilter.proto == 0 && len(expectedValues.appFilter.appIP) == 0 && expectedValues.appFilter.appPort.low == 0 && expectedValues.appFilter.appPort.high == 0 { @@ -258,7 +296,15 @@ func verifyP4RuntimeEntries(t *testing.T, testdata *pfcpSessionData, expectedVal // fmt.Sprintf("UP4 should have exactly %v p4RtEntries installed", expectedNumberOfAllEntries), // allInstalledEntries) - entries, _ := p4rtClient.ReadTableEntryWildcard("PreQosPipe.applications") + entries, _ := p4rtClient.ReadTableEntryWildcard("PreQosPipe.interfaces") + require.Equal(t, 2, len(entries)) + expectedInterfacesEntries := buildExpectedInterfacesEntries(p4rtClient, testdata, expectedValues) + n3addressEntry := expectedInterfacesEntries[0] + uePoolEntry := expectedInterfacesEntries[1] + require.Contains(t, entries, n3addressEntry) + require.Contains(t, entries, uePoolEntry) + + entries, _ = p4rtClient.ReadTableEntryWildcard("PreQosPipe.applications") require.Equal(t, expectedApplicationsEntries, len(entries), fmt.Sprintf("PreQosPipe.applications should contain %v entry", expectedApplicationsEntries)) if len(entries) > 0 { @@ -408,8 +454,10 @@ func verifyNoP4RuntimeEntries(t *testing.T, expectedValues p4RtValues) { // FIXME: tunnel_peers and applications are not cleared on session deletion/association release // See SDFAB-960 // Add tunnel_peers and applications to the list, once fixed - "PreQosPipe.sessions_uplink", "PreQosPipe.sessions_downlink", - "PreQosPipe.terminations_uplink", "PreQosPipe.terminations_downlink", + tablesNames[p4constants.TablePreQosPipeSessionsUplink], + tablesNames[p4constants.TablePreQosPipeSessionsDownlink], + tablesNames[p4constants.TablePreQosPipeTerminationsUplink], + tablesNames[p4constants.TablePreQosPipeTerminationsDownlink], } for _, table := range tables {