Skip to content

Commit

Permalink
Merge upstream main into upnode-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Henning committed Oct 1, 2024
2 parents f946aa3 + 0e55302 commit b94cc26
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 303 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func action(cliCtx *cli.Context) error {
}
factory.UERoutingConfig = ueRoutingCfg

pfcpStart, pfcpTerminate := utils.InitPFCPFunc()
pfcpStart, pfcpTerminate := utils.InitPFCPFunc(ctx)
smf, err := service.NewApp(ctx, cfg, tlsKeyLogPath, pfcpStart, pfcpTerminate)
if err != nil {
sigCh <- nil
Expand Down
4 changes: 2 additions & 2 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ type SMFContext struct {
OAuth2Required bool

UserPlaneInformation *UserPlaneInformation
Ctx context.Context
PFCPCancelFunc context.CancelFunc
PfcpContext context.Context
PfcpCancelFunc context.CancelFunc
PfcpHeartbeatInterval time.Duration

// Now only "IPv4" supported
Expand Down
2 changes: 1 addition & 1 deletion internal/context/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func (p *DataPath) AddChargingRules(smContext *SMContext, chgLevel ChargingLevel
// nolint
nodeId := node.GetUPFID()
logger.PduSessLog.Tracef("DownLinkTunnel add URR for node %s %+v",
nodeId, node.UpLinkTunnel.PDR)
nodeId, node.DownLinkTunnel.PDR)
}
}
}
Expand Down
53 changes: 27 additions & 26 deletions internal/context/sm_context_policy_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package context_test

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/free5gc/openapi/models"
"github.com/free5gc/smf/internal/context"
smf_context "github.com/free5gc/smf/internal/context"
"github.com/free5gc/smf/pkg/factory"
)

Expand Down Expand Up @@ -114,7 +115,7 @@ var testConfig = factory.Config{
}

func initConfig() {
context.InitSmfContext(&testConfig)
smf_context.InitSmfContext(&testConfig)
factory.SmfConfig = &testConfig
}

Expand All @@ -125,7 +126,7 @@ func TestApplySessionRules(t *testing.T) {
name string
decision *models.SmPolicyDecision
noErr bool
expectedSessRules map[string]*context.SessionRule
expectedSessRules map[string]*smf_context.SessionRule
}{
{
name: "nil decision",
Expand All @@ -151,7 +152,7 @@ func TestApplySessionRules(t *testing.T) {
},
},
},
expectedSessRules: map[string]*context.SessionRule{
expectedSessRules: map[string]*smf_context.SessionRule{
"SessRuleId-1": {
SessionRule: &models.SessionRule{
AuthSessAmbr: &models.Ambr{
Expand Down Expand Up @@ -192,7 +193,7 @@ func TestApplySessionRules(t *testing.T) {
},
},
},
expectedSessRules: map[string]*context.SessionRule{
expectedSessRules: map[string]*smf_context.SessionRule{
"SessRuleId-1": {
SessionRule: &models.SessionRule{
AuthSessAmbr: &models.Ambr{
Expand Down Expand Up @@ -250,7 +251,7 @@ func TestApplySessionRules(t *testing.T) {
},
},
},
expectedSessRules: map[string]*context.SessionRule{
expectedSessRules: map[string]*smf_context.SessionRule{
"SessRuleId-1": {
SessionRule: &models.SessionRule{
AuthSessAmbr: &models.Ambr{
Expand Down Expand Up @@ -295,7 +296,7 @@ func TestApplySessionRules(t *testing.T) {
"SessRuleId-1": nil,
},
},
expectedSessRules: map[string]*context.SessionRule{
expectedSessRules: map[string]*smf_context.SessionRule{
"SessRuleId-2": {
SessionRule: &models.SessionRule{
AuthSessAmbr: &models.Ambr{
Expand Down Expand Up @@ -328,7 +329,7 @@ func TestApplySessionRules(t *testing.T) {
},
}

smctx := context.NewSMContext("imsi-208930000000001", 10)
smctx := smf_context.NewSMContext("imsi-208930000000001", 10)

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -350,9 +351,9 @@ func TestApplyPccRules(t *testing.T) {
name string
decision *models.SmPolicyDecision
noErr bool
expectedPCCRules map[string]*context.PCCRule
expectedPCCRules map[string]*smf_context.PCCRule
expectedQosDatas map[string]*models.QosData
expectedTcDatas map[string]*context.TrafficControlData
expectedTcDatas map[string]*smf_context.TrafficControlData
}{
{
name: "nil decision",
Expand Down Expand Up @@ -390,7 +391,7 @@ func TestApplyPccRules(t *testing.T) {
},
},
},
expectedPCCRules: map[string]*context.PCCRule{
expectedPCCRules: map[string]*smf_context.PCCRule{
"PccRuleId-1": {
PccRule: &models.PccRule{
FlowInfos: []models.FlowInformation{
Expand All @@ -410,7 +411,7 @@ func TestApplyPccRules(t *testing.T) {
QosId: "QosId-1",
},
},
expectedTcDatas: map[string]*context.TrafficControlData{
expectedTcDatas: map[string]*smf_context.TrafficControlData{
"TcId-1": {
TrafficControlData: &models.TrafficControlData{
TcId: "TcId-1",
Expand Down Expand Up @@ -446,7 +447,7 @@ func TestApplyPccRules(t *testing.T) {
},
},
},
expectedPCCRules: map[string]*context.PCCRule{
expectedPCCRules: map[string]*smf_context.PCCRule{
"PccRuleId-1": {
PccRule: &models.PccRule{
FlowInfos: []models.FlowInformation{
Expand Down Expand Up @@ -482,7 +483,7 @@ func TestApplyPccRules(t *testing.T) {
QosId: "QosId-2",
},
},
expectedTcDatas: map[string]*context.TrafficControlData{
expectedTcDatas: map[string]*smf_context.TrafficControlData{
"TcId-1": {
TrafficControlData: &models.TrafficControlData{
TcId: "TcId-1",
Expand Down Expand Up @@ -518,7 +519,7 @@ func TestApplyPccRules(t *testing.T) {
},
},
},
expectedPCCRules: map[string]*context.PCCRule{
expectedPCCRules: map[string]*smf_context.PCCRule{
"PccRuleId-1": {
PccRule: &models.PccRule{
FlowInfos: []models.FlowInformation{
Expand Down Expand Up @@ -554,7 +555,7 @@ func TestApplyPccRules(t *testing.T) {
QosId: "QosId-3",
},
},
expectedTcDatas: map[string]*context.TrafficControlData{
expectedTcDatas: map[string]*smf_context.TrafficControlData{
"TcId-1": {
TrafficControlData: &models.TrafficControlData{
TcId: "TcId-1",
Expand All @@ -575,7 +576,7 @@ func TestApplyPccRules(t *testing.T) {
"PccRuleId-2": nil,
},
},
expectedPCCRules: map[string]*context.PCCRule{
expectedPCCRules: map[string]*smf_context.PCCRule{
"PccRuleId-1": {
PccRule: &models.PccRule{
FlowInfos: []models.FlowInformation{
Expand All @@ -595,7 +596,7 @@ func TestApplyPccRules(t *testing.T) {
QosId: "QosId-3",
},
},
expectedTcDatas: map[string]*context.TrafficControlData{
expectedTcDatas: map[string]*smf_context.TrafficControlData{
"TcId-1": {
TrafficControlData: &models.TrafficControlData{
TcId: "TcId-1",
Expand All @@ -616,20 +617,20 @@ func TestApplyPccRules(t *testing.T) {
"PccRuleId-1": nil,
},
},
expectedPCCRules: map[string]*context.PCCRule{},
expectedPCCRules: map[string]*smf_context.PCCRule{},
expectedQosDatas: map[string]*models.QosData{},
expectedTcDatas: map[string]*context.TrafficControlData{},
expectedTcDatas: map[string]*smf_context.TrafficControlData{},
noErr: true,
},
}

smfContext := context.GetSelf()
smfContext.UserPlaneInformation = context.NewUserPlaneInformation(userPlaneConfig)
for _, n := range smfContext.UserPlaneInformation.UPFs {
n.UPFStatus = context.AssociatedSetUpSuccess
smfContext := smf_context.GetSelf()
smfContext.UserPlaneInformation = smf_context.NewUserPlaneInformation(userPlaneConfig)
for _, upf := range smfContext.UserPlaneInformation.UPFs {
upf.AssociationContext = context.Background()
}

smctx := context.NewSMContext("imsi-208930000000002", 10)
smctx := smf_context.NewSMContext("imsi-208930000000002", 10)

smctx.SMLock.Lock()
defer smctx.SMLock.Unlock()
Expand Down Expand Up @@ -659,7 +660,7 @@ func TestApplyPccRules(t *testing.T) {
},
}
smctx.SelectedPDUSessionType = 1
smctx.SessionRules["SessRuleId-1"] = &context.SessionRule{
smctx.SessionRules["SessRuleId-1"] = &smf_context.SessionRule{
SessionRule: &models.SessionRule{
AuthSessAmbr: &models.Ambr{
Uplink: "1000 Kbps",
Expand Down
Loading

0 comments on commit b94cc26

Please sign in to comment.