From: Juha Hyttinen Date: Mon, 30 Dec 2019 09:55:36 +0000 (+0200) Subject: RICPLT-2957 Clean old test directory. Unittests can handle these cases X-Git-Tag: 0.4.0~60 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=586cbbc7da7e66d7143ec685012380d63f00cacd;p=ric-plt%2Fsubmgr.git RICPLT-2957 Clean old test directory. Unittests can handle these cases Change-Id: Iaba2d37b84bbfd49d9a2ac9ddb68f2d58dc85f8a Signed-off-by: Juha Hyttinen --- diff --git a/Dockerfile b/Dockerfile index 95070a7..b3ad890 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ # Abstract: Builds a container to compile Subscription Manager's code # Date: 28 May 2019 # -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:2-u18.04-nng as submgrbuild +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as submgrbuild RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb diff --git a/pkg/control/messaging_test.go b/pkg/control/messaging_test.go index e5d426b..60a5dc0 100644 --- a/pkg/control/messaging_test.go +++ b/pkg/control/messaging_test.go @@ -34,11 +34,14 @@ import ( var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer() +// +// +// func createSubsReq() *e2ap.E2APSubscriptionRequest { req := &e2ap.E2APSubscriptionRequest{} req.RequestId.Id = 1 - req.RequestId.Seq = 22 + req.RequestId.Seq = 0 req.FunctionId = 1 req.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true @@ -66,6 +69,9 @@ func createSubsReq() *e2ap.E2APSubscriptionRequest { return req } +// +// +// func createSubsResp(req *e2ap.E2APSubscriptionRequest) *e2ap.E2APSubscriptionResponse { resp := &e2ap.E2APSubscriptionResponse{} @@ -90,9 +96,32 @@ func createSubsResp(req *e2ap.E2APSubscriptionRequest) *e2ap.E2APSubscriptionRes return resp } +// +// +// +func createSubsDelReq(e2SubsId uint32) *e2ap.E2APSubscriptionDeleteRequest { + req := &e2ap.E2APSubscriptionDeleteRequest{} + req.RequestId.Id = 1 + req.RequestId.Seq = e2SubsId + req.FunctionId = 1 + return req +} + +// +// +// +func createSubsDelResp(req *e2ap.E2APSubscriptionDeleteRequest) *e2ap.E2APSubscriptionDeleteResponse { + resp := &e2ap.E2APSubscriptionDeleteResponse{} + resp.RequestId.Id = req.RequestId.Id + resp.RequestId.Seq = req.RequestId.Seq + resp.FunctionId = req.FunctionId + return resp +} + //----------------------------------------------------------------------------- // TestSubRequestSubResponseOk // +// stub stub // +-------+ +---------+ +---------+ // | xapp | | submgr | | e2term | // +-------+ +---------+ +---------+ @@ -109,27 +138,41 @@ func createSubsResp(req *e2ap.E2APSubscriptionRequest) *e2ap.E2APSubscriptionRes // | SubResp | | // |<-------------| | // | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | // //----------------------------------------------------------------------------- -func TestSubRequestSubResponseOk(t *testing.T) { +func TestSubReqAndSubDelOk(t *testing.T) { - xapp.Logger.Info("TestSimple start") + xapp.Logger.Info("TestSubReqAndSubDelOk start") e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest() e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse() + e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest() + e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse() + var e2SubsId int //--------------------------------- - // xapp activity + // xapp activity: Send Subs Req //--------------------------------- select { case <-time.After(5 * time.Second): + xapp.Logger.Info("(xappConn) Send Subs Req") req := createSubsReq() e2SubsReq.Set(req) xapp.Logger.Debug("%s", e2SubsReq.String()) err, packedMsg := e2SubsReq.Pack(nil) if err != nil { testError(t, "(xappConn) pack NOK %s", err.Error()) - } else { - xapp.Logger.Info("(xappConn) pack OK") } params := &xapp.RMRParams{} @@ -147,14 +190,14 @@ func TestSubRequestSubResponseOk(t *testing.T) { } //--------------------------------- - // e2term activity + // e2term activity: Recv Subs Req & Send Subs Resp //--------------------------------- select { case msg := <-e2termConn.rmrConChan: if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] { testError(t, "(e2termConn) Received non RIC_SUB_REQ message") } else { - + xapp.Logger.Info("(e2termConn) Recv Subs Req & Send Subs Resp") packedData := &packer.PackedData{} packedData.Buf = msg.Payload unpackerr := e2SubsReq.UnPack(packedData) @@ -172,8 +215,6 @@ func TestSubRequestSubResponseOk(t *testing.T) { packerr, packedMsg := e2SubsResp.Pack(nil) if packerr != nil { testError(t, "(e2termConn) pack NOK %s", packerr.Error()) - } else { - xapp.Logger.Info("(e2termConn) pack OK") } params := &xapp.RMRParams{} @@ -195,17 +236,20 @@ func TestSubRequestSubResponseOk(t *testing.T) { } //--------------------------------- - // xapp activity + // xapp activity: Recv Subs Resp //--------------------------------- select { case msg := <-xappConn.rmrConChan: if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] { testError(t, "(xappConn) Received non RIC_SUB_RESP message") } else { + xapp.Logger.Info("(xappConn) Recv Subs Resp") packedData := &packer.PackedData{} packedData.Buf = msg.Payload + e2SubsId = msg.SubId unpackerr := e2SubsResp.UnPack(packedData) + if unpackerr != nil { testError(t, "(xappConn) RIC_SUB_RESP unpack failed err: %s", unpackerr.Error()) } @@ -219,4 +263,105 @@ func TestSubRequestSubResponseOk(t *testing.T) { testError(t, "(xappConn) Not Received RIC_SUB_RESP within 15 secs") } + //--------------------------------- + // xapp activity: Send Subs Del Req + //--------------------------------- + select { + case <-time.After(2 * time.Second): + xapp.Logger.Info("(xappConn) Send Subs Del Req") + req := createSubsDelReq(uint32(e2SubsId)) + e2SubsDelReq.Set(req) + xapp.Logger.Debug("%s", e2SubsDelReq.String()) + err, packedMsg := e2SubsDelReq.Pack(nil) + if err != nil { + testError(t, "(xappConn) pack NOK %s", err.Error()) + } + + params := &xapp.RMRParams{} + params.Mtype = xapp.RIC_SUB_DEL_REQ + params.SubId = e2SubsId + params.Payload = packedMsg.Buf + params.Meid = &xapp.RMRMeid{RanName: "RAN_NAME_1"} + params.Xid = "XID_1" + params.Mbuf = nil + + snderr := xappConn.RmrSend(params) + if snderr != nil { + testError(t, "(xappConn) RMR SEND FAILED: %s", snderr.Error()) + } + } + + //--------------------------------- + // e2term activity: Recv Subs Del Req & Send Subs Del Resp + //--------------------------------- + select { + case msg := <-e2termConn.rmrConChan: + if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] { + testError(t, "(e2termConn) Received non RIC_SUB_DEL_REQ message") + } else { + xapp.Logger.Info("(e2termConn) Recv Subs Del Req & Send Subs Del Resp") + + packedData := &packer.PackedData{} + packedData.Buf = msg.Payload + unpackerr := e2SubsDelReq.UnPack(packedData) + if unpackerr != nil { + testError(t, "(e2termConn) RIC_SUB_DEL_REQ unpack failed err: %s", unpackerr.Error()) + } + geterr, req := e2SubsDelReq.Get() + if geterr != nil { + testError(t, "(e2termConn) RIC_SUB_DEL_REQ get failed err: %s", geterr.Error()) + } + + resp := createSubsDelResp(req) + e2SubsDelResp.Set(resp) + xapp.Logger.Debug("%s", e2SubsDelResp.String()) + packerr, packedMsg := e2SubsDelResp.Pack(nil) + if packerr != nil { + testError(t, "(e2termConn) pack NOK %s", packerr.Error()) + } + + params := &xapp.RMRParams{} + params.Mtype = xapp.RIC_SUB_DEL_RESP + params.SubId = msg.SubId + params.Payload = packedMsg.Buf + params.Meid = msg.Meid + params.Xid = msg.Xid + params.Mbuf = nil + + snderr := e2termConn.RmrSend(params) + if snderr != nil { + testError(t, "(e2termConn) RMR SEND FAILED: %s", snderr.Error()) + } + + } + case <-time.After(15 * time.Second): + testError(t, "(e2termConn) Not Received RIC_SUB_DEL_REQ within 15 secs") + } + + //--------------------------------- + // xapp activity: Recv Subs Del Resp + //--------------------------------- + select { + case msg := <-xappConn.rmrConChan: + if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] { + testError(t, "(xappConn) Received non RIC_SUB_DEL_RESP message") + } else { + xapp.Logger.Info("(xappConn) Recv Subs Del Resp") + + packedData := &packer.PackedData{} + packedData.Buf = msg.Payload + unpackerr := e2SubsDelResp.UnPack(packedData) + if unpackerr != nil { + testError(t, "(xappConn) RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error()) + } + geterr, _ := e2SubsDelResp.Get() + if geterr != nil { + testError(t, "(xappConn) RIC_SUB_DEL_RESP get failed err: %s", geterr.Error()) + } + + } + case <-time.After(15 * time.Second): + testError(t, "(xappConn) Not Received RIC_SUB_DEL_RESP within 15 secs") + } + } diff --git a/test/dbaas/README.md b/test/dbaas/README.md deleted file mode 100644 index 87f8f16..0000000 --- a/test/dbaas/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# DBaaS Stub Platform Component -## General Description -__DBaaS__ is a Stub provides SDL backend Stub for xApp-Frame based components -* vanilla Redis instace from DockerHub - diff --git a/test/dbaas/manifests/dbaas-dep.yaml b/test/dbaas/manifests/dbaas-dep.yaml deleted file mode 100644 index 8fe571a..0000000 --- a/test/dbaas/manifests/dbaas-dep.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: DBaaS Stub Platform Component Kubernetes manifest -# Date: 28 May 2019 -# -apiVersion: apps/v1 -kind: Deployment -metadata: - name: dbaas - namespace: ricplt -spec: - replicas: 1 - selector: - matchLabels: - app: dbaas - template: - metadata: - labels: - app: dbaas - spec: - containers: - - name: dbaas - image: redis - ports: - - containerPort: 6379 diff --git a/test/dbaas/manifests/dbaas-svc.yaml b/test/dbaas/manifests/dbaas-svc.yaml deleted file mode 100644 index bd5ed8a..0000000 --- a/test/dbaas/manifests/dbaas-svc.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: DBaaS Stub Platform Component service manifest -# Date: 28 May 2019 -# -kind: Service -apiVersion: v1 -metadata: - name: dbaas - namespace: ricplt -spec: - selector: - app: dbaas - clusterIP: None - ports: - - name: redis - port: 6379 - protocol: TCP - diff --git a/test/e2t/README.md b/test/e2t/README.md deleted file mode 100644 index 5e5c7b4..0000000 --- a/test/e2t/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# E2T Test platform component -Base project: https://gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp -## General Description -__E2T__ is a platform component stub which has following behaviors -* Receives, decodes and prints out the content of RMR messages -* Sends Subscription Response message (12011) to each RMR message using it's sub_id -* Sends Subscription Response with invalid subscription ID in every 14 second -* Sends Subscription Response with malformed payload in every 14 second -* Set `E2T_RAWDATA` to override default encoded payload (use hex dump format) - - diff --git a/test/e2t/build.sh b/test/e2t/build.sh deleted file mode 100755 index 07a7548..0000000 --- a/test/e2t/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -e -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Mnemonic: test/e2t/build.sh -# Abstract: Creates E2T Stub Platform Component docker container -# Date: 28 May 2019 -# - -echo 'Creating E2T container' -docker build --no-cache --tag=e2t:builder -f container/Dockerfile ../.. diff --git a/test/e2t/container/Dockerfile b/test/e2t/container/Dockerfile deleted file mode 100644 index e3855f7..0000000 --- a/test/e2t/container/Dockerfile +++ /dev/null @@ -1,87 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: Builds E2T stub container -# Date: 28 May 2019 -# - -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:1-u18.04-nng1.1.1 as submgrbuild - -# Install RMr shared library -RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_1.9.0_amd64.deb/download.deb && dpkg -i rmr_1.9.0_amd64.deb && rm -rf rmr_1.9.0_amd64.deb -# Install RMr development header files -RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_1.9.0_amd64.deb/download.deb && dpkg -i rmr-dev_1.9.0_amd64.deb && rm -rf rmr-dev_1.9.0_amd64.deb - -# "PULLING LOG and COMPILING LOG" -RUN git clone "https://gerrit.o-ran-sc.org/r/com/log" /opt/log && cd /opt/log && \ - ./autogen.sh && ./configure && make install && ldconfig - -WORKDIR /opt/submgr - -# "COMPILING E2AP Wrapper" -COPY e2ap e2ap -RUN cd /opt/submgr/e2ap && \ - gcc -c -fPIC -Iheaders/ lib/*.c wrapper.c && \ - gcc *.o -shared -o libwrapper.so && \ - cp libwrapper.so /usr/local/lib/ && \ - cp wrapper.h headers/*.h /usr/local/include/ && \ - ldconfig - -# "Installing Swagger" -RUN cd /usr/local/go/bin \ - && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \ - && mv swagger_linux_amd64 swagger \ - && chmod +x swagger - -# "Getting and generating routing managers api client" -COPY api api -RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \ - && cp rtmgr/api/routing_manager.yaml api/ \ - && rm -rf rtmgr - -RUN mkdir pkg - -COPY go.mod go.mod - -RUN mkdir -p /root/go && \ - /usr/local/go/bin/swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client - -COPY go.mod go.mod - -RUN /usr/local/go/bin/go mod tidy - -#Compiling E2T -COPY pkg pkg -COPY cmd cmd -COPY test test - -RUN mkdir -p /opt/bin && \ - /usr/local/go/bin/go build -o /opt/test/e2t/e2t ./test/e2t/e2t.go && \ - mkdir -p /opt/test/e2t/container/usr/local - -FROM ubuntu:18.04 - -COPY --from=submgrbuild /opt/test/e2t/e2t / -COPY test/e2t/e2t.yaml test/e2t/container/run_e2t.sh / -COPY --from=submgrbuild /usr/local/include /usr/local/include -COPY --from=submgrbuild /usr/local/lib /usr/local/lib - -RUN ldconfig - -RUN chmod 755 /run_e2t.sh diff --git a/test/e2t/container/run_e2t.sh b/test/e2t/container/run_e2t.sh deleted file mode 100755 index f5b3c97..0000000 --- a/test/e2t/container/run_e2t.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Mnemonic: run_e2t.sh -# Abstract: Starts the E2T stub platform service -# Date: 28 May 2019 -# -exec ./e2t -f /e2t.yaml diff --git a/test/e2t/e2t.go b/test/e2t/e2t.go deleted file mode 100644 index 88bc250..0000000 --- a/test/e2t/e2t.go +++ /dev/null @@ -1,154 +0,0 @@ -/* -================================================================================== - Copyright (c) 2019 AT&T Intellectual Property. - Copyright (c) 2019 Nokia - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -================================================================================== -*/ - -package main - -/* -#include -#include - -#cgo CFLAGS: -I../ -#cgo LDFLAGS: -lrmr_nng -lnng -*/ -import "C" - -import ( - "encoding/hex" - "errors" - submgr "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/control" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" - "github.com/spf13/viper" - "strconv" -) - -type E2t struct { - submgr.E2ap -} - -var c chan xapp.RMRParams = make(chan xapp.RMRParams, 1) - -var requestRawData string -var deleteRawData string - -func init() { - viper.AutomaticEnv() - viper.SetEnvPrefix("e2t") - viper.AllowEmptyEnv(true) - requestRawData = viper.GetString("rawdata") - if requestRawData == "" { - requestRawData = "20c9001d000003ea7e00050000010002ea6300020003ea6c000700ea6d40020004" - } - xapp.Logger.Info("Initial RAW Data: %v", requestRawData) - deleteRawData = viper.GetString("rawdata") - if deleteRawData == "" { - deleteRawData = "20ca0012000002ea7e00050000010002ea6300020003" - } - xapp.Logger.Info("Initial RAW Data: %v", deleteRawData) -} - -func (e *E2t) GenerateRequestPayload(subId uint16) (payload []byte, err error) { - skeleton, err := hex.DecodeString(requestRawData) - if err != nil { - return make([]byte, 0), errors.New("unable to decode data provided in \"RCO_RAWDATA\" environment variable") - } - payload, err = e.SetSubscriptionResponseSequenceNumber(skeleton, subId) - return -} - -func (e *E2t) GenerateDeletePayload(subId uint16) (payload []byte, err error) { - skeleton, err := hex.DecodeString(deleteRawData) - if err != nil { - return make([]byte, 0), errors.New("unable to decode data provided in \"RCO_RAWDATA\" environment variable") - } - payload, err = e.SetSubscriptionDeleteResponseSequenceNumber(skeleton, subId) - return -} - -func (e E2t) Consume(rp *xapp.RMRParams) (err error) { - switch rp.Mtype { - case C.RIC_SUB_REQ: - err = e.handleSubscriptionRequest(rp) - case C.RIC_SUB_DEL_REQ: - err = e.handleSubscriptionDeleteRequest(rp) - default: - err = errors.New("Message Type " + strconv.Itoa(rp.Mtype) + " is discarded") - xapp.Logger.Error("Unknown message type: %v", err) - } - return -} - -func (e E2t) handleSubscriptionRequest(request *xapp.RMRParams) (err error) { - payloadSeqNum, err := e.GetSubscriptionRequestSequenceNumber(request.Payload) - if err != nil { - xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - xapp.Logger.Info("Subscription Request Received: RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", payloadSeqNum, payloadSeqNum) - payload, err := e.GenerateRequestPayload(payloadSeqNum) - if err != nil { - xapp.Logger.Debug(err.Error()) - return - } - request.Payload = payload - request.Mtype = 12011 - c <- *request - return -} - -func (e E2t) handleSubscriptionDeleteRequest(request *xapp.RMRParams) (err error) { - payloadSeqNum, err := e.GetSubscriptionDeleteRequestSequenceNumber(request.Payload) - if err != nil { - xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - xapp.Logger.Info("Subscription Delete Request Received: RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", payloadSeqNum, payloadSeqNum) - payload, err := e.GenerateDeletePayload(payloadSeqNum) - if err != nil { - xapp.Logger.Debug(err.Error()) - return - } - request.Payload = payload - request.Mtype = 12021 - c <- *request - return -} - -func (e *E2t) Run() { - for { - message := <-c - var payloadSeqNum uint16 - var err error - if message.Mtype == 12011 { - payloadSeqNum, err = e.GetSubscriptionResponseSequenceNumber(message.Payload) - } else if message.Mtype == 12021 { - payloadSeqNum, err = e.GetSubscriptionDeleteResponseSequenceNumber(message.Payload) - } else { - err = errors.New("OH MY GOD") - } - if err != nil { - xapp.Logger.Debug("Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - xapp.Logger.Info("Sending Message: TYPE: %v | RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v)", message.Mtype, message.SubId, payloadSeqNum) - xapp.Rmr.Send(&message, true) - } -} - -func main() { - e2t := E2t{} - go e2t.Run() - xapp.Run(e2t) -} diff --git a/test/e2t/e2t.yaml b/test/e2t/e2t.yaml deleted file mode 100644 index 0060727..0000000 --- a/test/e2t/e2t.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"local": - "host": ":8080" -"logger": - "level": 3 -"rmr": - "protPort": "tcp:4560" - "maxSize": 2072 - "numWorkers": 1 diff --git a/test/e2t/manifests/e2t-dep.yaml b/test/e2t/manifests/e2t-dep.yaml deleted file mode 100644 index 64967c7..0000000 --- a/test/e2t/manifests/e2t-dep.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: E2T Stub Plaform component Kubernetes manifest -# Date: 28 May 2019 -# -apiVersion: apps/v1 -kind: Deployment -metadata: - name: e2t - namespace: ricplt -spec: - replicas: 1 - selector: - matchLabels: - app: e2t - template: - metadata: - labels: - app: e2t - spec: - containers: - - name: e2t - image: jenkins:5000/e2t:test - command: ["/run_e2t.sh"] - env: - - name: DBAAS_SERVICE_HOST - value: dbaas - - name: E2T_RAWDATA - value: 000001ea7e000500aaaabbbb - ports: - - containerPort: 8080 - - containerPort: 4560 - - containerPort: 4561 diff --git a/test/e2t/manifests/e2t-svc.yaml b/test/e2t/manifests/e2t-svc.yaml deleted file mode 100644 index 03b6a75..0000000 --- a/test/e2t/manifests/e2t-svc.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: E2T Stub Platform service manifest -# Date: 28 May 2019 -# -kind: Service -apiVersion: v1 -metadata: - name: e2t - namespace: ricplt -spec: - selector: - app: e2t - clusterIP: None - ports: - - name: nbi - port: 8080 - protocol: TCP - - name: sbi-data - port: 4560 - protocol: TCP - - name: sbi-control - port: 4561 - protocol: TCP - diff --git a/test/rco/README.md b/test/rco/README.md deleted file mode 100644 index 3ba74b6..0000000 --- a/test/rco/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# RCO Test xApp Instance -Base project: https://gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp -## General Description -__RCO__ is an xApp instance which has following behaviors -* sends valid SUB_REQ RMR message periodically in every 2 second. -* sends invalid message (10000) message in every 14 second -* sends subscription requsts (12010) with malformed payload in every 14 seconds -* receives RMR messages and emmits log on it's standard output -* default initial sequence number is `12345`. Set `RCO_SEED_SN` environment variable to override -* Set `RCO_RAWDATA` to override default encoded payload (use hex dump format) - - - - diff --git a/test/rco/build.sh b/test/rco/build.sh deleted file mode 100755 index 517a8a6..0000000 --- a/test/rco/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -e -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Mnemonic: test/rco/build.sh -# Abstract: Creates RCO Stub xApp docker container -# Date: 28 May 2019 -# - -echo 'Creating RCO container' -docker build --no-cache --tag=rco:builder -f container/Dockerfile ../.. diff --git a/test/rco/container/Dockerfile b/test/rco/container/Dockerfile deleted file mode 100644 index 8687618..0000000 --- a/test/rco/container/Dockerfile +++ /dev/null @@ -1,92 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: Builds RCO stub container -# Date: 28 May 2019 -# - -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:1-u18.04-nng1.1.1 as submgrbuild - -ENV HTTP_PROXY=http://10.144.1.10:8080 -ENV HTTPS_PROXY=http://10.144.1.10:8080 -RUN echo 'use_proxy=yes \n http_proxy=http://10.144.1.10:8080 \n https_proxy=http://10.144.1.10:8080' > /etc/wgetrc -RUN echo 'Acquire::http::Proxy "http://87.254.212.121:8080/";' > /etc/apt/apt.conf - -# Install RMr shared library -RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_1.6.0_amd64.deb/download.deb && dpkg -i rmr_1.6.0_amd64.deb -# Install RMr development header files -RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_1.6.0_amd64.deb/download.deb && dpkg -i rmr-dev_1.6.0_amd64.deb - -# "PULLING LOG and COMPILING LOG" -RUN git clone "https://gerrit.o-ran-sc.org/r/com/log" /opt/log && cd /opt/log && \ - ./autogen.sh && ./configure && make install && ldconfig - -WORKDIR /opt/submgr - -# "COMPILING E2AP Wrapper" -COPY e2ap e2ap -RUN cd e2ap && \ - gcc -c -fPIC -Iheaders/ lib/*.c wrapper.c && \ - gcc *.o -shared -o libwrapper.so && \ - cp libwrapper.so /usr/local/lib/ && \ - cp wrapper.h headers/*.h /usr/local/include/ && \ - ldconfig - -# "Installing Swagger" -RUN cd /usr/local/go/bin \ - && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \ - && mv swagger_linux_amd64 swagger \ - && chmod +x swagger - -# "Getting and generating routing managers api client" -COPY api api -RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \ - && cp rtmgr/api/routing_manager.yaml api/ \ - && rm -rf rtmgr - -RUN mkdir pkg - -COPY go.mod go.mod - -RUN mkdir -p /root/go && \ - /usr/local/go/bin/swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client - -COPY go.mod go.mod - -RUN /usr/local/go/bin/go mod tidy - -#Compiling RCO -COPY pkg pkg -COPY cmd cmd -COPY test test - -RUN mkdir -p /opt/bin && \ - /usr/local/go/bin/go build -o /opt/test/rco/rco ./test/rco/rco.go && \ - mkdir -p /opt/test/rco/container/usr/local - -FROM ubuntu:18.04 - -COPY --from=submgrbuild /opt/test/rco/rco / -COPY test/rco/rco.yaml test/rco/container/run_rco.sh test/uta_rtg.rt / -COPY --from=submgrbuild /usr/local/include /usr/local/include -COPY --from=submgrbuild /usr/local/lib /usr/local/lib - -RUN ldconfig -RUN chmod 755 /run_rco.sh -RUN chmod 755 /rco diff --git a/test/rco/container/run_rco.sh b/test/rco/container/run_rco.sh deleted file mode 100755 index 1bcb1ed..0000000 --- a/test/rco/container/run_rco.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Mnemonic: run_rco.sh -# Abstract: Starts the rco xApp stub -# Date: 28 May 2019 -# -exec ./rco -f /rco.yaml diff --git a/test/rco/manifests/rco-dep.yaml b/test/rco/manifests/rco-dep.yaml deleted file mode 100644 index 871c3a8..0000000 --- a/test/rco/manifests/rco-dep.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: RCO Stub xApp Kubernetes manifest -# Date: 28 May 2019 -# -apiVersion: apps/v1 -kind: Deployment -metadata: - name: rco - namespace: ricplt -spec: - replicas: 1 - selector: - matchLabels: - app: rco - template: - metadata: - labels: - app: rco - spec: - containers: - - name: rco - image: jenkins:5000/rco:test - command: ["/run_rco.sh"] - env: - - name: DBAAS_SERVICE_HOST - value: dbaas - - name: RCO_RAWDATA - value: 000003ea7e000500aaaaccccea6300020000ea81000e00045465737400ea6b0003000100 - - name: RCO_SEED_SN - value: "9999" - - name: RMR_SEED_RT - value: uta_rtg.rt - - ports: - - containerPort: 8080 - - containerPort: 4560 - - containerPort: 4561 - imagePullPolicy: Always diff --git a/test/rco/manifests/rco-svc.yaml b/test/rco/manifests/rco-svc.yaml deleted file mode 100644 index 1648231..0000000 --- a/test/rco/manifests/rco-svc.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# -#================================================================================== -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#================================================================================== -# -# -# Abstract: RCO Stub xApp service manifest -# Date: 28 May 2019 -# -kind: Service -apiVersion: v1 -metadata: - name: rco - namespace: ricplt -spec: - selector: - app: rco - clusterIP: None - ports: - - name: nbi - port: 8080 - protocol: TCP - - name: sbi-data - port: 4560 - protocol: TCP - - name: sbi-control - port: 4561 - protocol: TCP - diff --git a/test/rco/rco.go b/test/rco/rco.go deleted file mode 100644 index 646bb42..0000000 --- a/test/rco/rco.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -================================================================================== - Copyright (c) 2019 AT&T Intellectual Property. - Copyright (c) 2019 Nokia - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -================================================================================== -*/ - -package main - -import ( - "encoding/hex" - "errors" - submgr "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/control" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" - "github.com/spf13/viper" - "os" - "strconv" - "time" -) - -type Rco struct { - submgr.E2ap -} - -var c = make(chan submgr.RmrDatagram, 1) -var params xapp.RMRParams - -var requestRawData string -var deleteRawData string -var seedSN uint16 -var deleteSeedSN uint16 - -func init() { - viper.AutomaticEnv() - viper.SetEnvPrefix("rco") - viper.AllowEmptyEnv(true) - requestRawData = viper.GetString("rawdata") - if requestRawData == "" { - requestRawData = "00c90020000003ea7e00050000010002ea6300020003ea81000a000000ea6b4003000440" - } - deleteRawData = viper.GetString("deleterawdata") - if deleteRawData == "" { - deleteRawData = "00ca0012000002ea7e00050000010002ea6300020003" - } - xapp.Logger.Info("Initial RAW DATA: %v", requestRawData) - xapp.Logger.Info("Initial DELETE RAW DATA: %v", deleteRawData) - seedSN = uint16(viper.GetInt("seed_sn")) - if seedSN == 0 || seedSN > 65535 { - seedSN = 12345 - } - deleteSeedSN = uint16(viper.GetInt("delete_seed_sn")) - if deleteSeedSN == 0 || deleteSeedSN > 65535 { - deleteSeedSN = seedSN - } - - xapp.Logger.Info("Initial SEQUENCE NUMBER: %v", seedSN) -} - -func (r *Rco) GeneratePayload(subId uint16) (payload []byte, err error) { - skeleton, err := hex.DecodeString(requestRawData) - if err != nil { - return make([]byte, 0), errors.New("nable to decode data provided in \"RCO_RAWDATA\" environment variable") - } - payload, err = r.SetSubscriptionRequestSequenceNumber(skeleton, subId) - return -} - -func (r *Rco) GenerateDeletePayload(subId uint16) (payload []byte, err error) { - skeleton, err := hex.DecodeString(deleteRawData) - if err != nil { - return make([]byte, 0), errors.New("unable to decode data provided in \"RCO_DELETERAWDATA\" environment variable") - } - payload, err = r.SetSubscriptionDeleteRequestSequenceNumber(skeleton, subId) - return -} - -func (r Rco) Consume(params *xapp.RMRParams) (err error) { - switch params.Mtype { - case xapp.RICMessageTypes["RIC_SUB_RESP"]: - payloadSeqNum, err := r.GetSubscriptionResponseSequenceNumber(params.Payload) - if err != nil { - xapp.Logger.Error("SUBRESP: Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - xapp.Logger.Info("Subscription Response Message Received: RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum) - return err - case xapp.RICMessageTypes["RIC_SUB_DEL_RESP"]: - payloadSeqNum, err := r.GetSubscriptionDeleteResponseSequenceNumber(params.Payload) - if err != nil { - xapp.Logger.Error("DELRESP: Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - xapp.Logger.Info("Subscription Delete Response Message Received: RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum) - return err - default: - err = errors.New("Message Type " + strconv.Itoa(params.Mtype) + " is discarded") - xapp.Logger.Error("Unknown message type: %v", err) - return - } -} - -func (r *Rco) SendRequests() (err error) { - message, err := r.GeneratePayload(seedSN) - if err != nil { - xapp.Logger.Debug(err.Error()) - return - } - deletemessage, err := r.GenerateDeletePayload(deleteSeedSN) - if err != nil { - xapp.Logger.Debug(err.Error()) - return - } - for { - time.Sleep(5 * time.Second) - c <- submgr.RmrDatagram{MessageType: 12010, SubscriptionId: seedSN, Payload: message} - seedSN++ - time.Sleep(5 * time.Second) - c <- submgr.RmrDatagram{MessageType: 12020, SubscriptionId: deleteSeedSN, Payload: deletemessage} - deleteSeedSN++ - } -} - -func (r *Rco) Run() { - for { - message := <-c - payloadSeqNum, err := r.GetSubscriptionRequestSequenceNumber(message.Payload) - if err != nil { - xapp.Logger.Debug("Unable to get Subscription Sequence Number from Payload due to: " + err.Error()) - } - params.SubId = int(message.SubscriptionId) - params.Mtype = message.MessageType - params.PayloadLen = len(message.Payload) - params.Payload = message.Payload - xapp.Logger.Info("Sending Message: TYPE: %v | RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v)", message.MessageType, message.SubscriptionId, payloadSeqNum) - xapp.Rmr.Send(¶ms, false) - } -} - -func (r *Rco) sendInvalidTestMessages() { - for { - time.Sleep(7 * time.Second) - c <- submgr.RmrDatagram{MessageType: 10000, SubscriptionId: 0, Payload: make([]byte, 1)} - time.Sleep(7 * time.Second) - c <- submgr.RmrDatagram{MessageType: 12010, SubscriptionId: 0, Payload: make([]byte, 1)} - } -} - -func main() { - rco := Rco{} - go xapp.Rmr.Start(rco) - go rco.Run() - go rco.sendInvalidTestMessages() - err := rco.SendRequests() - if err != nil { - xapp.Logger.Info("Error: %v", err) - os.Exit(1) - } -} diff --git a/test/rco/rco.yaml b/test/rco/rco.yaml deleted file mode 100644 index 0060727..0000000 --- a/test/rco/rco.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2019 AT&T Intellectual Property. -# Copyright (c) 2019 Nokia. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"local": - "host": ":8080" -"logger": - "level": 3 -"rmr": - "protPort": "tcp:4560" - "maxSize": 2072 - "numWorkers": 1 diff --git a/test/uta_rtg.rt b/test/uta_rtg.rt deleted file mode 100644 index 792e9a7..0000000 --- a/test/uta_rtg.rt +++ /dev/null @@ -1,6 +0,0 @@ -newrt|start -rte|12010,172.17.0.3:4560|172.17.0.4:4560 -rte|12010,172.17.0.4:4560|172.17.0.6:4560 -rte|12011,172.17.0.6:4560|172.17.0.4:4560 -rte|10000,172.17.0.3:4560|172.17.0.4:4560 -newrt|end