Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mbilal92/ausf into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilal92 committed Oct 19, 2024
2 parents 8ec5f2f + 2e1b65b commit 9a40658
Show file tree
Hide file tree
Showing 21 changed files with 254 additions and 218 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/master.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Copyright 2023 Canonical Ltd.
# Copyright 2024 Intel Corporation

name: Master workflow
name: Main workflow

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
build:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
go-version-file: 'go.mod'

- name: golangci-lint
uses: golangci/[email protected].0
uses: golangci/[email protected].1
with:
version: latest
args: -v --config ./.golangci.yml
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: GitHub release and Docker images
on:
push:
branches:
- master
- main
tags:
- v*

Expand All @@ -32,16 +32,16 @@ jobs:
username: ${{ secrets.AETHER_REGISTRY_USERNAME }}
password: ${{ secrets.AETHER_REGISTRY_PASSWORD }}

- name: Build and push "master-latest" Docker image
- name: Build and push "main-latest" Docker image
env:
DOCKER_TAG: master-latest
DOCKER_TAG: main-latest
run: |
make docker-build
make docker-push
- name: Build and push "master-GIT_SHA" Docker image
- name: Build and push "main-GIT_SHA" Docker image
env:
DOCKER_TAG: master-${{ env.GIT_SHA_SHORT }}
DOCKER_TAG: main-${{ env.GIT_SHA_SHORT }}
run: |
make docker-build
make docker-push
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.23.1-bookworm AS builder
FROM golang:1.23.2-bookworm AS builder

LABEL maintainer="Aether SD-Core <[email protected]>"

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.3-dev
1.5.1-dev
6 changes: 3 additions & 3 deletions ausf.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import (
"fmt"
"os"

"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"go.uber.org/zap"

"github.com/omec-project/ausf/logger"
"github.com/omec-project/ausf/service"
)

var AUSF = &service.AUSF{}

var appLog *logrus.Entry
var appLog *zap.SugaredLogger

func init() {
appLog = logger.AppLog
Expand All @@ -35,7 +35,7 @@ func init() {
func main() {
app := cli.NewApp()
app.Name = "ausf"
fmt.Print(app.Name, "\n")
appLog.Infoln(app.Name)
app.Usage = "-free5gccfg common configuration file -ausfcfg ausf configuration file"
app.Action = action
app.Flags = AUSF.GetCliCmd()
Expand Down
30 changes: 15 additions & 15 deletions ausf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ func TestRegisterNF(t *testing.T) {
consumer.SendSearchNFInstances = origSearchNFInstances
consumer.SendUpdateNFInstance = origUpdateNFInstance
}()
fmt.Printf("test case TestRegisterNF")
t.Logf("test case TestRegisterNF")
var prof models.NfProfile
consumer.SendRegisterNFInstance = func(nrfUri string, nfInstanceId string, profile models.NfProfile) (models.NfProfile, string, string, error) {
prof = profile
prof.HeartBeatTimer = 1
fmt.Printf("test RegisterNFInstance called")
t.Logf("test RegisterNFInstance called")
return prof, "", "", nil
}
consumer.SendSearchNFInstances = func(nrfUri string, targetNfType, requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {
fmt.Printf("test SearchNFInstance called")
t.Logf("test SearchNFInstance called")
return models.SearchResult{}, nil
}
consumer.SendUpdateNFInstance = func(patchItem []models.PatchItem) (nfProfile models.NfProfile, problemDetails *models.ProblemDetails, err error) {
Expand All @@ -80,7 +80,7 @@ func TestRegisterNF(t *testing.T) {
}

func TestGetUDMUri(t *testing.T) {
fmt.Printf("test cases for Get UDM URI")
t.Logf("test cases for Get UDM URI")
callCountSearchNFInstances := 0
callCountSendNfDiscovery := 0
origNRFCacheSearchNFInstances := consumer.NRFCacheSearchNFInstances
Expand Down Expand Up @@ -172,12 +172,12 @@ func TestGetUDMUri(t *testing.T) {
consumer.SendNfDiscoveryToNrf = origSendNfDiscoveryToNrf
}()
consumer.NRFCacheSearchNFInstances = func(nrfUri string, targetNfType, requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {
fmt.Printf("test SearchNFInstance called")
t.Logf("test SearchNFInstance called")
callCountSearchNFInstances++
return searchResult1, nil
}
consumer.SendNfDiscoveryToNrf = func(nrfUri string, targetNfType, requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {
fmt.Printf("test SendNfDiscoveryToNrf called")
t.Logf("test SendNfDiscoveryToNrf called")
callCountSendNfDiscovery++
return searchResult2, nil
}
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestGetUDMUri(t *testing.T) {
}

func TestCreateSubscriptionSuccess(t *testing.T) {
fmt.Printf("test cases for CreateSubscription")
t.Logf("test cases for CreateSubscription")
udmProfile := models.NfProfile{
UdmInfo: &models.UdmInfo{
RoutingIndicators: []string{},
Expand Down Expand Up @@ -256,11 +256,11 @@ func TestCreateSubscriptionSuccess(t *testing.T) {
consumer.CreateSubscription = origCreateSubscription
}()
consumer.StoreApiSearchNFInstances = func(*Nnrf_NFDiscovery.NFInstancesStoreApiService, context.Context, models.NfType, models.NfType, *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, *http.Response, error) {
fmt.Printf("test SearchNFInstances called")
t.Logf("test SearchNFInstances called")
return searchResult, &httpResponse, nil
}
consumer.CreateSubscription = func(nrfUri string, nrfSubscriptionData models.NrfSubscriptionData) (nrfSubData models.NrfSubscriptionData, problemDetails *models.ProblemDetails, err error) {
fmt.Printf("test SendCreateSubscription called")
t.Logf("test SendCreateSubscription called")
callCountSendCreateSubscription++
return models.NrfSubscriptionData{
NfStatusNotificationUri: "https://:0/nausf-callback/v1/nf-status-notify",
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestCreateSubscriptionSuccess(t *testing.T) {
}

func TestCreateSubscriptionFail(t *testing.T) {
fmt.Printf("test cases for CreateSubscription")
t.Logf("test cases for CreateSubscription")
udmProfile := models.NfProfile{
UdmInfo: &models.UdmInfo{
RoutingIndicators: []string{},
Expand Down Expand Up @@ -435,12 +435,12 @@ func TestCreateSubscriptionFail(t *testing.T) {
for i := range parameters {
t.Run(fmt.Sprintf("CreateSubscription testname %v result %v", parameters[i].testName, parameters[i].result), func(t *testing.T) {
consumer.StoreApiSearchNFInstances = func(*Nnrf_NFDiscovery.NFInstancesStoreApiService, context.Context, models.NfType, models.NfType, *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, *http.Response, error) {
fmt.Printf("test SearchNFInstances called")
t.Logf("test SearchNFInstances called")
return parameters[i].searchResult, &parameters[i].httpResponse, nil
}

consumer.CreateSubscription = func(nrfUri string, nrfSubscriptionData models.NrfSubscriptionData) (nrfSubData models.NrfSubscriptionData, problemDetails *models.ProblemDetails, err error) {
fmt.Printf("test SendCreateSubscription called")
t.Logf("test SendCreateSubscription called")
callCountSendCreateSubscription++
return parameters[i].nrfSubscriptionData, parameters[i].subscriptionProblem, parameters[i].subscriptionError
}
Expand All @@ -456,7 +456,7 @@ func TestCreateSubscriptionFail(t *testing.T) {
}

func TestNfSubscriptionStatusNotify(t *testing.T) {
fmt.Printf("test cases for NfSubscriptionStatusNotify")
t.Logf("test cases for NfSubscriptionStatusNotify")
callCountSendRemoveSubscription := 0
callCountNRFCacheRemoveNfProfileFromNrfCache := 0
origSendRemoveSubscription := consumer.SendRemoveSubscription
Expand All @@ -466,12 +466,12 @@ func TestNfSubscriptionStatusNotify(t *testing.T) {
producer.NRFCacheRemoveNfProfileFromNrfCache = origNRFCacheRemoveNfProfileFromNrfCache
}()
consumer.SendRemoveSubscription = func(subscriptionId string) (problemDetails *models.ProblemDetails, err error) {
fmt.Printf("test SendRemoveSubscription called")
t.Logf("test SendRemoveSubscription called")
callCountSendRemoveSubscription++
return nil, nil
}
producer.NRFCacheRemoveNfProfileFromNrfCache = func(nfInstanceId string) bool {
fmt.Printf("test NRFCacheRemoveNfProfileFromNrfCache called")
t.Logf("test NRFCacheRemoveNfProfileFromNrfCache called")
callCountNRFCacheRemoveNfProfileFromNrfCache++
return true
}
Expand Down
2 changes: 1 addition & 1 deletion callback/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Routes []Route

// NewRouter returns a new router.
func NewRouter() *gin.Engine {
router := loggerUtil.NewGinWithLogrus(logger.GinLog)
router := loggerUtil.NewGinWithZap(logger.GinLog)
AddService(router)
return router
}
Expand Down
10 changes: 5 additions & 5 deletions consumer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ var SendRegisterNFInstance = func(nrfUri, nfInstanceId string, profile models.Nf
retrieveNfInstanceId = resourceUri[strings.LastIndex(resourceUri, "/")+1:]
return prof, resourceNrfUri, retrieveNfInstanceId, nil
} else {
fmt.Println(fmt.Errorf("handler returned wrong status code %d", status))
fmt.Println(fmt.Errorf("NRF return wrong status code %d", status))
logger.ConsumerLog.Errorf("handler returned wrong status code %d", status)
logger.ConsumerLog.Errorf("NRF return wrong status code %d", status)
}
}
return prof, "", "", nil
}

func SendDeregisterNFInstance() (*models.ProblemDetails, error) {
logger.AppLog.Infof("Send Deregister NFInstance")
logger.AppLog.Infoln("send Deregister NFInstance")

ausfSelf := ausfContext.GetSelf()
// Set client and set url
Expand Down Expand Up @@ -109,7 +109,7 @@ func SendDeregisterNFInstance() (*models.ProblemDetails, error) {
}

var SendUpdateNFInstance = func(patchItem []models.PatchItem) (nfProfile models.NfProfile, problemDetails *models.ProblemDetails, err error) {
logger.ConsumerLog.Debugf("Send Update NFInstance")
logger.ConsumerLog.Debugln("send Update NFInstance")

ausfSelf := ausfContext.GetSelf()
configuration := Nnrf_NFManagement.NewConfiguration()
Expand Down Expand Up @@ -139,7 +139,7 @@ var SendUpdateNFInstance = func(patchItem []models.PatchItem) (nfProfile models.
}

var SendCreateSubscription = func(nrfUri string, nrfSubscriptionData models.NrfSubscriptionData) (nrfSubData models.NrfSubscriptionData, problemDetails *models.ProblemDetails, err error) {
logger.ConsumerLog.Debugf("send Create Subscription")
logger.ConsumerLog.Debugln("send Create Subscription")

// Set client and set url
configuration := Nnrf_NFManagement.NewConfiguration()
Expand Down
9 changes: 4 additions & 5 deletions context/ausf_context_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package context

import (
"fmt"
"os"
"strconv"
"time"
Expand All @@ -31,7 +30,7 @@ func TestInit() {

func InitAusfContext(context *AUSFContext) {
config := factory.AusfConfig
logger.InitLog.Infof("ausfconfig Info: Version[%s] Description[%s]\n", config.Info.Version, config.Info.Description)
logger.InitLog.Infof("ausfconfig Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description)

configuration := config.Configuration
sbi := configuration.Sbi
Expand Down Expand Up @@ -68,11 +67,11 @@ func InitAusfContext(context *AUSFContext) {

context.BindingIPv4 = os.Getenv(sbi.BindingIPv4)
if context.BindingIPv4 != "" {
logger.InitLog.Info("Parsing ServerIPv4 address from ENV Variable.")
logger.InitLog.Infoln("parsing ServerIPv4 address from ENV Variable")
} else {
context.BindingIPv4 = sbi.BindingIPv4
if context.BindingIPv4 == "" {
logger.InitLog.Warn("Error parsing ServerIPv4 address as string. Using the 0.0.0.0 address as default.")
logger.InitLog.Warnln("error parsing ServerIPv4 address as string. Using the 0.0.0.0 address as default")
context.BindingIPv4 = "0.0.0.0"
}
}
Expand All @@ -96,7 +95,7 @@ func InitAusfContext(context *AUSFContext) {
// context.NfService
context.NfService = make(map[models.ServiceName]models.NfService)
AddNfServices(&context.NfService, &config, context)
fmt.Println("ausf context = ", context)
logger.ContextLog.Infoln("ausf context:", context)
}

func AddNfServices(serviceMap *map[models.ServiceName]models.NfService, config *factory.Config, context *AUSFContext) {
Expand Down
5 changes: 2 additions & 3 deletions factory/ausf_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package factory

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -16,7 +15,7 @@ import (
// Webui URL is not set then default Webui URL value is returned
func TestGetDefaultWebuiUrl(t *testing.T) {
if err := InitConfigFactory("ausfcfg.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
t.Logf("error in InitConfigFactory: %v", err)
}
got := AusfConfig.Configuration.WebuiUri
want := "webui:9876"
Expand All @@ -26,7 +25,7 @@ func TestGetDefaultWebuiUrl(t *testing.T) {
// Webui URL is set to a custom value then custom Webui URL is returned
func TestGetCustomWebuiUrl(t *testing.T) {
if err := InitConfigFactory("ausfcfg_with_custom_webui_url.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
t.Logf("error in InitConfigFactory: %v", err)
}
got := AusfConfig.Configuration.WebuiUri
want := "myspecialwebui:9872"
Expand Down
31 changes: 15 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ go 1.21

require (
github.com/antihax/optional v1.0.0
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/bronze1man/radius v0.0.0-20190516032554-afd8baec892d
github.com/gin-gonic/gin v1.10.0
github.com/google/gopacket v1.1.19
github.com/google/uuid v1.6.0
github.com/omec-project/config5g v1.4.4
github.com/omec-project/openapi v1.2.1
github.com/omec-project/util v1.1.0
github.com/prometheus/client_golang v1.20.3
github.com/sirupsen/logrus v1.9.3
github.com/omec-project/config5g v1.5.1
github.com/omec-project/openapi v1.3.1
github.com/omec-project/util v1.2.3
github.com/prometheus/client_golang v1.20.5
github.com/stretchr/testify v1.9.0
github.com/urfave/cli v1.22.15
github.com/urfave/cli v1.22.16
go.uber.org/zap v1.27.0
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -27,7 +26,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand All @@ -40,7 +39,6 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -56,14 +54,15 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.2 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/h2non/gock.v1 v1.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 9a40658

Please sign in to comment.