Skip to content

Commit

Permalink
Verify interfaces entries in the integration tests (#554)
Browse files Browse the repository at this point in the history
* Verify interfaces entries in the integration tests

* Fix assertion for UE pool
  • Loading branch information
Tomasz Osiński committed Mar 12, 2022
1 parent ab5fc9e commit 4fabd1f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
11 changes: 8 additions & 3 deletions test/integration/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +78,7 @@ func UP4ConfigDefault() pfcpiface.Conf {
}

config.CPIface = pfcpiface.CPIfaceInfo{
UEIPPool: "10.250.0.0/16",
UEIPPool: UEPoolCP,
}

return config
Expand All @@ -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
Expand Down
54 changes: 51 additions & 3 deletions test/integration/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4fabd1f

Please sign in to comment.