Skip to content

Commit

Permalink
Pdubuilder test (#4)
Browse files Browse the repository at this point in the history
* added GHA for ccc service model
* Splitted the pdubuilder into top level messeges and add unit tests
  • Loading branch information
Agarwal-Shivansh authored May 20, 2024
1 parent 2f1f4cd commit 9a5dac0
Show file tree
Hide file tree
Showing 18 changed files with 862 additions and 2,922 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/esm_ccc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation

name: e2sm_ccc
on:
push:
branches:
- master
pull_request:

env:
E2T_MOD: github.com/onosproject/onos-e2t@master
ONOS_E2_SM_VERSION: latest

jobs:
e2sm_ccc:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./servicemodels/e2sm_ccc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
run: go build -o build/_output/e2sm_ccc.so.1.0.0 -buildmode=plugin .

- name: Unit tests
run: go test -race ./...

- name: docker-build
run: |
cd ../..
./build/bin/build-deps e2sm_ccc $E2T_MOD onosproject/service-model-docker-e2sm_ccc-1.0.0:$ONOS_E2_SM_VERSION
docker build . -f build/plugins/Dockerfile \
--build-arg PLUGIN_MAKE_TARGET="e2sm_ccc" \
--build-arg PLUGIN_MAKE_VERSION="1.0.0" \
-t onosproject/service-model-docker-e2sm_ccc-1.0.0:$ONOS_E2_SM_VERSION
64 changes: 64 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/cc-action-definition_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
"testing"

e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"
"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIcactionDefinition(t *testing.T) {
ricStyleType := &e2smcommoniesv1.RicStyleType{}
actionDefinitionFormat := &e2smcccv1.ActionDefinitionFormat{}
result, err := CreateE2SmCCcRIcactionDefinition(ricStyleType, actionDefinitionFormat)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateListOfRanconfigurationStructuresForAdf(t *testing.T) {
validItem := &e2smcccv1.RanconfigurationStructureForAdf{
//TODO
}
var value []*e2smcccv1.RanconfigurationStructureForAdf
for i := 0; i < 1; i++ {
value = append(value, validItem)
}
result, err := CreateListOfRanconfigurationStructuresForAdf(value)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateE2SmCCcActionDefinitionFormat1(t *testing.T) {
validItem := &e2smcccv1.RanconfigurationStructureForAdf{
//TODO
}
var value []*e2smcccv1.RanconfigurationStructureForAdf
for i := 0; i < 1; i++ {
value = append(value, validItem)
}
listOfNodeLevelRanconfigurationStructuresForAdf := &e2smcccv1.ListOfRanconfigurationStructuresForAdf{
Value: value,
}
result, err := CreateE2SmCCcActionDefinitionFormat1(listOfNodeLevelRanconfigurationStructuresForAdf)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateE2SmCCcActionDefinitionFormat2(t *testing.T) {
var value []*e2smcccv1.CellConfigurationToBeReportedForAdf
for i := 0; i < 1; i++ {
value = append(value, &e2smcccv1.CellConfigurationToBeReportedForAdf{
// TODO
})
}
listOfCellConfigurationsToBeReportedForAdf := &e2smcccv1.ListOfCellConfigurationsToBeReportedForAdf{
Value: value,
}
result, err := CreateE2SmCCcActionDefinitionFormat2(listOfCellConfigurationsToBeReportedForAdf)
assert.NoError(t, err)
assert.NotNil(t, result)
}
59 changes: 59 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-action-definition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"

"github.com/onosproject/onos-lib-go/pkg/errors"
)

func CreateE2SmCCcRIcactionDefinition(ricStyleType *e2smcommoniesv1.RicStyleType, actionDefinitionFormat *e2smcccv1.ActionDefinitionFormat) (*e2smcccv1.E2SmCCcRIcactionDefinition, error) {

msg := &e2smcccv1.E2SmCCcRIcactionDefinition{}
msg.RicStyleType = ricStyleType
msg.ActionDefinitionFormat = actionDefinitionFormat

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcRIcactionDefinition() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateListOfRanconfigurationStructuresForAdf(value []*e2smcccv1.RanconfigurationStructureForAdf) (*e2smcccv1.ListOfRanconfigurationStructuresForAdf, error) {

msg := &e2smcccv1.ListOfRanconfigurationStructuresForAdf{}
msg.Value = value

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateListOfRanconfigurationStructuresForAdf() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateE2SmCCcActionDefinitionFormat1(listOfNodeLevelRanconfigurationStructuresForAdf *e2smcccv1.ListOfRanconfigurationStructuresForAdf) (*e2smcccv1.E2SmCCcActionDefinitionFormat1, error) {

msg := &e2smcccv1.E2SmCCcActionDefinitionFormat1{}
msg.ListOfNodeLevelRanconfigurationStructuresForAdf = listOfNodeLevelRanconfigurationStructuresForAdf

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcActionDefinitionFormat1() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateE2SmCCcActionDefinitionFormat2(listOfCellConfigurationsToBeReportedForAdf *e2smcccv1.ListOfCellConfigurationsToBeReportedForAdf) (*e2smcccv1.E2SmCCcActionDefinitionFormat2, error) {

msg := &e2smcccv1.E2SmCCcActionDefinitionFormat2{}
msg.ListOfCellConfigurationsToBeReportedForAdf = listOfCellConfigurationsToBeReportedForAdf

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcActionDefinitionFormat2() error validating PDU %s", err.Error())
}
return msg, nil
}
34 changes: 34 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-header.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"
"github.com/onosproject/onos-lib-go/pkg/errors"
)

func CreateE2SmCCcRIcControlHeader(controlHeaderFormat *e2smcccv1.ControlHeaderFormat) (*e2smcccv1.E2SmCCcRIcControlHeader, error) {

msg := &e2smcccv1.E2SmCCcRIcControlHeader{}
msg.ControlHeaderFormat = controlHeaderFormat

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcRIcControlHeader() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateE2SmCCcControlHeaderFormat1(ricStyleType *e2smcommoniesv1.RicStyleType) (*e2smcccv1.E2SmCCcControlHeaderFormat1, error) {

msg := &e2smcccv1.E2SmCCcControlHeaderFormat1{}
msg.RicStyleType = ricStyleType

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcControlHeaderFormat1() error validating PDU %s", err.Error())
}

return msg, nil
}
27 changes: 27 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-header_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
"testing"

e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"
"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIcControlHeader(t *testing.T) {

controlHeaderFormat := &e2smcccv1.ControlHeaderFormat{}
result, err := CreateE2SmCCcRIcControlHeader(controlHeaderFormat)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateE2SmCCcControlHeaderFormat1(t *testing.T) {
ricStyleType := &e2smcommoniesv1.RicStyleType{}
result, err := CreateE2SmCCcControlHeaderFormat1(ricStyleType)
assert.NoError(t, err)
assert.NotNil(t, result)
}
59 changes: 59 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/onosproject/onos-lib-go/pkg/errors"
)

func CreateE2SmCCcRIcControlMessage(controlMessageFormat *e2smcccv1.ControlMessageFormat) (*e2smcccv1.E2SmCCcRIcControlMessage, error) {

msg := &e2smcccv1.E2SmCCcRIcControlMessage{}
msg.ControlMessageFormat = controlMessageFormat

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcRIcControlMessage() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateE2SmCCcControlMessageFormat1(listOfConfigurationStructures *e2smcccv1.ListOfConfigurationStructures) (*e2smcccv1.E2SmCCcControlMessageFormat1, error) {

msg := &e2smcccv1.E2SmCCcControlMessageFormat1{}
msg.ListOfConfigurationStructures = listOfConfigurationStructures

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcControlMessageFormat1() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateConfigurationStructureWrite(ranConfigurationStructureName *e2smcccv1.RanConfigurationStructureName, oldValuesOfAttributes *e2smcccv1.ValuesOfAttributes, newValuesOfAttributes *e2smcccv1.ValuesOfAttributes) (*e2smcccv1.ConfigurationStructureWrite, error) {

msg := &e2smcccv1.ConfigurationStructureWrite{}
msg.RanConfigurationStructureName = ranConfigurationStructureName
msg.OldValuesOfAttributes = oldValuesOfAttributes
msg.NewValuesOfAttributes = newValuesOfAttributes

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateConfigurationStructureWrite() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateE2SmCCcControlMessageFormat2(listOfCellsReported *e2smcccv1.ListOfCells) (*e2smcccv1.E2SmCCcControlMessageFormat2, error) {

msg := &e2smcccv1.E2SmCCcControlMessageFormat2{}
msg.ListOfCellsReported = listOfCellsReported

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcControlMessageFormat2() error validating PDU %s", err.Error())
}

return msg, nil
}
53 changes: 53 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-message_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
"testing"

e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIcControlMessage(t *testing.T) {
controlMessageFormat := &e2smcccv1.ControlMessageFormat{}
result, err := CreateE2SmCCcRIcControlMessage(controlMessageFormat)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateE2SmCCcControlMessageFormat1(t *testing.T) {
var value []*e2smcccv1.ConfigurationStructureWrite
for i := 0; i < 1; i++ {
value = append(value, &e2smcccv1.ConfigurationStructureWrite{})
}
listOfConfigurationStructures := &e2smcccv1.ListOfConfigurationStructures{
Value: value,
}
result, err := CreateE2SmCCcControlMessageFormat1(listOfConfigurationStructures)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateConfigurationStructureWrite(t *testing.T) {
ranConfigurationStructureName := &e2smcccv1.RanConfigurationStructureName{}
oldValuesOfAttributes := &e2smcccv1.ValuesOfAttributes{}
newValuesOfAttributes := &e2smcccv1.ValuesOfAttributes{}
result, err := CreateConfigurationStructureWrite(ranConfigurationStructureName, oldValuesOfAttributes, newValuesOfAttributes)
assert.NoError(t, err)
assert.NotNil(t, result)
}

func TestCreateE2SmCCcControlMessageFormat2(t *testing.T) {
var value []*e2smcccv1.CellControlled
for i := 0; i < 1; i++ {
value = append(value, &e2smcccv1.CellControlled{})
}
listOfCellsReported := &e2smcccv1.ListOfCells{
Value: value,
}
result, err := CreateE2SmCCcControlMessageFormat2(listOfCellsReported)
assert.NoError(t, err)
assert.NotNil(t, result)
}
51 changes: 51 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-outcome.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023-present Intel Corporation

package pdubuilder

import (
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/onosproject/onos-lib-go/pkg/errors"
)

func CreateE2SmCCcRIcControlOutcome(controlOutcomeFormat *e2smcccv1.ControlOutcomeFormat) (*e2smcccv1.E2SmCCcRIcControlOutcome, error) {

msg := &e2smcccv1.E2SmCCcRIcControlOutcome{}
msg.ControlOutcomeFormat = controlOutcomeFormat

if err := msg.Validate(); err != nil {
return nil, errors.NewInvalid("CreateE2SmCCcRIcControlOutcome() error validating PDU %s", err.Error())
}

return msg, nil
}

func CreateControlOutcomeFormatE2SmCccControlOutcomeFormat1(e2SmCccControlOutcomeFormat1 *e2smcccv1.E2SmCCcControlOutcomeFormat1) (*e2smcccv1.ControlOutcomeFormat, error) {

item := &e2smcccv1.ControlOutcomeFormat{
ControlOutcomeFormat: &e2smcccv1.ControlOutcomeFormat_E2SmCccControlOutcomeFormat1{
E2SmCccControlOutcomeFormat1: e2SmCccControlOutcomeFormat1,
},
}

if err := item.Validate(); err != nil {
return nil, errors.NewInvalid("CreateControlOutcomeFormatE2SmCccControlOutcomeFormat1() error validating PDU %s", err.Error())
}

return item, nil
}

func CreateControlOutcomeFormatE2SmCccControlOutcomeFormat2(e2SmCccControlOutcomeFormat2 *e2smcccv1.E2SmCCcControlOutcomeFormat2) (*e2smcccv1.ControlOutcomeFormat, error) {

item := &e2smcccv1.ControlOutcomeFormat{
ControlOutcomeFormat: &e2smcccv1.ControlOutcomeFormat_E2SmCccControlOutcomeFormat2{
E2SmCccControlOutcomeFormat2: e2SmCccControlOutcomeFormat2,
},
}

if err := item.Validate(); err != nil {
return nil, errors.NewInvalid("CreateControlOutcomeFormatE2SmCccControlOutcomeFormat2() error validating PDU %s", err.Error())
}

return item, nil
}
Loading

0 comments on commit 9a5dac0

Please sign in to comment.