#----------------------------------------------------------
#
#----------------------------------------------------------
-FROM ubuntu:16.04 as xapp-base
+FROM ubuntu:16.04 as appmgr-xapp-base
RUN apt-get update -y && \
apt-get install -y wget
# rancodev libs
#
RUN mkdir -p /opt/build \
+ && cd /opt/build && git clone https://gerrit.oran-osc.org/r/ric-plt/lib/rmr \
+ && cd rmr/; mkdir build; cd build; cmake ..; make install \
&& cd /opt/build && git clone https://gerrit.oran-osc.org/r/com/log \
&& cd log/ ; ./autogen.sh ; ./configure ; make ; make install \
&& ldconfig
-COPY build/build_entrypoint.sh /
COPY build/user_entrypoint.sh /
-RUN chmod +x /build_entrypoint.sh
RUN chmod +x /user_entrypoint.sh
RUN mkdir -p /ws
#----------------------------------------------------------
#
#----------------------------------------------------------
-FROM xapp-base as appmgr-build
+FROM appmgr-xapp-base as appmgr-build
ARG PACKAGEURL
-ARG PACKAGEREPO
-ARG SSH_PRIVATE_KEY
-ARG NETRC_CONFIG
ARG HELMVERSION
# Module prepare (if go.mod/go.sum updated)
COPY go.mod /go/src/${PACKAGEURL}
COPY go.sum /go/src/${PACKAGEURL}
-RUN GO111MODULE=on /build_entrypoint.sh go mod download
+RUN GO111MODULE=on go mod download
# build
COPY . /go/src/${PACKAGEURL}
-RUN /build_entrypoint.sh make -C /go/src/${PACKAGEURL} build
+RUN make -C /go/src/${PACKAGEURL} build
-ENTRYPOINT ["/build_entrypoint.sh"]
CMD ["/bin/bash"]
RUN mkdir -p /opt/xAppManager \
&& chmod -R 755 /opt/xAppManager
-COPY --from=appmgr-build /go/src/${PACKAGEURL}/build/cache/cmd/appmgr /opt/xAppManager/appmgr
+COPY --from=appmgr-build /go/src/${PACKAGEURL}/cache/go/cmd/appmgr /opt/xAppManager/appmgr
#COPY --from=appmgr-build /go/src/${PACKAGEURL}/config/appmgr.yaml /opt/etc/xAppManager/config-file.yaml
#------------------------------------------------------------------------------
#
-# Build and test targets
-#
#------------------------------------------------------------------------------
ROOT_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
-BUILD_DIR:=$(abspath $(ROOT_DIR)/build)
+CACHE_DIR?=$(abspath $(ROOT_DIR)/cache)
+#------------------------------------------------------------------------------
+#
+# Build and test targets
+#
+#------------------------------------------------------------------------------
XAPP_NAME:=appmgr
XAPP_ROOT:=cmd
XAPP_TESTENV:="RMR_SEED_RT=config/uta_rtg.rt CFG_FILE=$(ROOT_DIR)helm_chart/uemgr/descriptors/config-file.json"
include build/make.go.mk
-
#------------------------------------------------------------------------------
#
# DOCKER TARGETS
PACKAGEURL:="gerrit.oran-osc.org/r/ric-plt/appmgr"
+DCKR_NAME:=appmgr-xapp-base
+include build/make.docker.mk
+
DCKR_NAME:=appmgr-test_unit
include build/make.docker.mk
include build/make.docker.mk
-docker-test: docker-run_appmgr-test_fmt docker-run_appmgr-test_sanity docker-run-redished_appmgr-test_unit
+docker-test: docker-run-stop_appmgr-test_fmt docker-run-stop_appmgr-test_sanity docker-run-stop_appmgr-test_unit
"swagger": "2.0",
"info": {
"description": "This is a draft API for RIC appmgr",
- "version": "0.1.2",
+ "version": "0.1.3",
"title": "RIC appmgr",
"license": {
"name": "Apache 2.0",
"http"
],
"paths": {
- "/health": {
+ "/health/alive": {
"get": {
- "summary": "Health check of xApp Manager",
+ "summary": "Health check of xApp Manager - Liveness probe",
"tags": [
"health"
],
- "operationId": "getHealth",
+ "operationId": "getHealthAlive",
"responses": {
"200": {
"description": "Status of xApp Manager is ok"
}
}
},
+ "/health/ready": {
+ "get": {
+ "summary": "Readiness check of xApp Manager - Readiness probe",
+ "tags": [
+ "health"
+ ],
+ "operationId": "getHealthReady",
+ "responses": {
+ "200": {
+ "description": "xApp Manager is ready for service"
+ },
+ "503": {
+ "description": "xApp Manager is not ready for service"
+ }
+ }
+ }
+ },
"/xapps": {
"post": {
"summary": "Deploy a xapp",
"schema": {
"type": "object",
"required": [
- "xAppName"
+ "name"
],
"properties": {
- "xAppName": {
- "type":"string",
- "description":"Name of the xApp",
+ "name": {
+ "type": "string",
+ "description": "Name of the xApp.",
+ "example": "xapp-dummy"
+ },
+ "configName": {
+ "type": "string",
+ "description": "Name of the xApp configmap. Overrides the value given in Helm chart value file.",
+ "example": "xapp-dummy-configmap"
+ },
+ "namespace": {
+ "type": "string",
+ "description": "Name of the namespace to which xApp is deployed. Overrides the value given in Helm chart value file.",
+ "example": "ricxapps"
+ },
+ "serviceName": {
+ "type": "string",
+ "description": "Name of the service xApp is providing. Overrides the value given in Helm chart value file.",
+ "example": "xapp-dummy-service"
+ },
+ "imageRepo": {
+ "type": "string",
+ "description": "Name of the docker repository xApp is located. Overrides the value given in Helm chart value file.",
+ "example": "xapprepo"
+ },
+ "hostname": {
+ "type": "string",
+ "description": "Hostname for the pod. Used by messaging library. Overrides the value given in Helm chart value file.",
"example": "xapp-dummy"
}
}
],
"parameters": [
{
- "name": "xAppConfig",
+ "name": "XAppConfig",
"in": "body",
"description": "xApp config",
"schema": {
- "$ref": "#/definitions/xAppConfig"
+ "$ref": "#/definitions/XAppConfig"
}
}
],
"201": {
"description": "xApp config successfully created",
"schema": {
- "$ref": "#/definitions/xAppConfig"
+ "$ref": "#/definitions/XAppConfig"
}
},
"400": {
],
"parameters": [
{
- "name": "xAppConfig",
+ "name": "XAppConfig",
"in": "body",
"description": "xApp config",
"schema": {
- "$ref": "#/definitions/xAppConfig"
+ "$ref": "#/definitions/XAppConfig"
}
}
],
"200": {
"description": "xApp config successfully modified",
"schema": {
- "$ref": "#/definitions/xAppConfig"
+ "$ref": "#/definitions/XAppConfig"
}
},
"400": {
"operationId": "deleteXappConfig",
"parameters": [
{
- "name": "xAppConfigInfo",
+ "name": "ConfigMetadata",
"in": "body",
"description": "xApp configuration information",
"schema": {
- "$ref": "#/definitions/xAppConfigInfo"
+ "$ref": "#/definitions/ConfigMetadata"
}
}
],
"in": "path",
"description": "ID of subscription",
"required": true,
- "type": "integer"
+ "type": "string"
}
],
"responses": {
"in": "path",
"description": "ID of subscription",
"required": true,
- "type": "integer"
+ "type": "string"
},
{
"in": "body",
"in": "path",
"description": "ID of subscription",
"required": true,
- "type": "integer"
+ "type": "string"
}
],
"responses": {
"type": "integer",
"example": 32300
},
- "txMessages" : {
+ "txMessages": {
"type": "array",
"items": {
- "type" : "string",
- "example" : "ControlIndication"
+ "type": "string",
+ "example": "ControlIndication"
}
},
- "rxMessages" : {
+ "rxMessages": {
"type": "array",
"items": {
- "type" : "string",
- "example" : "LoadIndication"
+ "type": "string",
+ "example": "LoadIndication"
}
}
}
},
- "xAppConfigInfo": {
+ "ConfigMetadata": {
"type": "object",
"required": [
- "xAppName",
- "configMapName",
+ "name",
+ "configName",
"namespace"
],
"properties": {
- "xAppName": {
- "type":"string",
- "description":"Name of the xApp",
+ "name": {
+ "type": "string",
+ "description": "Name of the xApp",
"example": "xapp-dummy"
},
- "configMapName": {
- "type":"string",
- "description":"Name of the config map",
+ "configName": {
+ "type": "string",
+ "description": "Name of the config map",
"example": "xapp-dummy-config-map"
},
"namespace": {
- "type":"string",
- "description":"Name of the namespace",
+ "type": "string",
+ "description": "Name of the namespace",
"example": "ricxapp"
}
}
},
- "xAppConfig": {
+ "XAppConfig": {
"type": "object",
"required": [
- "xAppConfigInfo",
- "configSchema",
- "configMap"
+ "metadata",
+ "descriptor",
+ "config"
],
"properties": {
- "xAppConfigInfo": {
- "$ref": "#/definitions/xAppConfigInfo"
+ "metadata": {
+ "$ref": "#/definitions/ConfigMetadata"
},
- "configSchema": {
- "type":"object",
- "description":"Schema of configuration in JSON format"
+ "descriptor": {
+ "type": "object",
+ "description": "Schema of configuration in JSON format"
},
- "configMap": {
- "type":"object",
- "description":"Configuration in JSON format"
+ "config": {
+ "type": "object",
+ "description": "Configuration in JSON format"
}
}
},
"AllXappConfig": {
"type": "array",
"items": {
- "$ref": "#/definitions/xAppConfig"
+ "$ref": "#/definitions/XAppConfig"
}
},
"subscriptionRequest": {
swagger: '2.0'
info:
description: This is a draft API for RIC appmgr
- version: 0.1.2
+ version: 0.1.3
title: RIC appmgr
license:
name: Apache 2.0
- https
- http
paths:
- /health:
- get:
- summary: Health check of xApp Manager
- tags:
+ /health/alive :
+ get :
+ summary : Health check of xApp Manager - Liveness probe
+ tags :
- health
- operationId: getHealth
- responses:
+ operationId : getHealthAlive
+ responses :
+ '200' :
+ description : Status of xApp Manager is ok
+ /health/ready :
+ get :
+ summary : Readiness check of xApp Manager - Readiness probe
+ tags :
+ - health
+ operationId : getHealthReady
+ responses :
'200':
- description: Status of xApp Manager is ok
+ description : xApp Manager is ready for service
+ '503':
+ description: xApp Manager is not ready for service
/xapps:
post:
summary: Deploy a xapp
schema:
type: object
required:
- - xAppName
+ - name
properties:
- xAppName:
+ name:
type: string
- description: Name of the xApp
+ description: Name of the xApp.
+ example: xapp-dummy
+ configName:
+ type: string
+ description: Name of the xApp configmap. Overrides the value given in Helm chart value file.
+ example: xapp-dummy-configmap
+ namespace:
+ type: string
+ description: Name of the namespace to which xApp is deployed. Overrides the value given in Helm chart value file.
+ example: ricxapps
+ serviceName:
+ type: string
+ description: Name of the service xApp is providing. Overrides the value given in Helm chart value file.
+ example: xapp-dummy-service
+ imageRepo:
+ type: string
+ description: Name of the docker repository xApp is located. Overrides the value given in Helm chart value file.
+ example: xapprepo
+ hostname:
+ type: string
+ description: Hostname for the pod. Used by messaging library. Overrides the value given in Helm chart value file.
example: xapp-dummy
responses:
'201':
produces:
- application/json
parameters:
- - name: xAppConfig
+ - name: XAppConfig
in: body
description: xApp config
schema:
- $ref: '#/definitions/xAppConfig'
+ $ref: '#/definitions/XAppConfig'
responses:
'201':
description: xApp config successfully created
schema:
- $ref: '#/definitions/xAppConfig'
+ $ref: '#/definitions/XAppConfig'
'400':
description: Invalid input
'422':
produces:
- application/json
parameters:
- - name: xAppConfig
+ - name: XAppConfig
in: body
description: xApp config
schema:
- $ref: '#/definitions/xAppConfig'
+ $ref: '#/definitions/XAppConfig'
responses:
'200':
description: xApp config successfully modified
schema:
- $ref: '#/definitions/xAppConfig'
+ $ref: '#/definitions/XAppConfig'
'400':
description: Invalid input
'422':
- xapp
operationId: deleteXappConfig
parameters:
- - name: xAppConfigInfo
+ - name: ConfigMetadata
in: body
description: xApp configuration information
schema:
- $ref: '#/definitions/xAppConfigInfo'
+ $ref: '#/definitions/ConfigMetadata'
responses:
'204':
description: Successful deletion of xApp
in: path
description: ID of subscription
required: true
- type: integer
+ type: string
responses:
'200':
description: successful operation
in: path
description: ID of subscription
required: true
- type: integer
+ type: string
- in: body
name: subscriptionRequest
description: Modified subscription
in: path
description: ID of subscription
required: true
- type: integer
+ type: string
responses:
'204':
description: Successful deletion of subscription
items:
type: string
example: LoadIndication
- xAppConfigInfo:
+ ConfigMetadata:
type: object
required:
- - xAppName
- - configMapName
+ - name
+ - configName
- namespace
properties:
- xAppName:
+ name:
type: string
description: Name of the xApp
example: xapp-dummy
- configMapName:
+ configName:
type: string
description: Name of the config map
example: xapp-dummy-config-map
type: string
description: Name of the namespace
example: ricxapp
- xAppConfig:
+ XAppConfig:
type: object
required:
- - xAppConfigInfo
- - configSchema
- - configMap
+ - metadata
+ - descriptor
+ - config
properties:
- xAppConfigInfo:
- $ref: '#/definitions/xAppConfigInfo'
- configSchema:
+ metadata:
+ $ref: '#/definitions/ConfigMetadata'
+ descriptor:
type: object
description: Schema of configuration in JSON format
- configMap:
+ config:
type: object
description: Configuration in JSON format
AllXappConfig:
type: array
items:
- $ref: '#/definitions/xAppConfig'
+ $ref: '#/definitions/XAppConfig'
subscriptionRequest:
type: object
required:
ifndef MAKE_DOCKER_TARGETS
MAKE_DOCKER_TARGETS:=1
-.PHONY: docker-build docker-clean
+.PHONY: docker-build docker-clean docker-stop FORCE
+
+FORCE:
docker-name_%:
@echo $($*_DCKR_FULLNAME)
+
docker-build_%:
- @(\
- test -z "$${SSH_PRIVATE_KEY}" && SSH_PRIVATE_KEY=$$(cat $${HOME}/.ssh/id_rsa);\
- docker build --target $* $($*_DCKR_B_OPTS) --build-arg SSH_PRIVATE_KEY="$${SSH_PRIVATE_KEY}" -t $($*_DCKR_FULLNAME) -f $($*_DCKR_FILE) . ;\
- )
-
-docker-irun_%:
- docker run $($*_DCKR_R_OPTS) $($*_DCKR_FULLNAME) /bin/bash
-
-docker-irun-mounted_%:
- docker run $($*_DCKR_R_OPTS) -v $(shell pwd):/ws/go/src/${PACKAGEURL} --workdir "/ws/go/src/${PACKAGEURL}" $($*_DCKR_FULLNAME) /bin/bash
-
-docker-run_%:
- docker run $($*_DCKR_R_OPTS) $($*_DCKR_FULLNAME)
-
-docker-run-redished_%:
- @( \
- RETVAL=0;\
- docker network create --driver bridge $($*_DCKR_FULLNAME)-run_network;\
- docker run $($*_DCKR_R_OPTS) -d --name $($*_DCKR_FULLNAME)-run_redis --network $($*_DCKR_FULLNAME)-run_network redis;\
- docker run $($*_DCKR_R_OPTS) --name $($*_DCKR_FULLNAME)-run_xapp --network $($*_DCKR_FULLNAME)-run_network -e DBAAS_SERVICE_HOST=$($*_DCKR_FULLNAME)-run_redis $($*_DCKR_FULLNAME);\
- RETVAL=$$?;\
- docker stop $($*_DCKR_FULLNAME)-run_redis;\
- docker network rm $($*_DCKR_FULLNAME)-run_network;\
- exit $${RETVAL};\
- )
-
-docker-clean_%:
+ docker build --target $* $($*_DCKR_B_OPTS) -t $($*_DCKR_FULLNAME) -f $($*_DCKR_FILE) .
+
+.docker-services-drun_%:
+ docker network create --driver bridge $($*_DCKR_FULLNAME)-running_network
+ docker run $($*_DCKR_R_OPTS) -d --name $($*_DCKR_FULLNAME)-running_redis --network $($*_DCKR_FULLNAME)-running_network redis
+
+docker-irun_%: .docker-services-drun_%
+ docker run $($*_DCKR_R_OPTS) --name $($*_DCKR_FULLNAME)-running_xapp --network $($*_DCKR_FULLNAME)-running_network -e DBAAS_SERVICE_HOST=$($*_DCKR_FULLNAME)-running_redis $($*_DCKR_FULLNAME) /bin/bash
+
+docker-irun-mounted_%: .docker-services-drun_%
+ docker run $($*_DCKR_R_OPTS) -v $(shell pwd):/ws/go/src/${PACKAGEURL} --workdir "/ws/go/src/${PACKAGEURL}" --name $($*_DCKR_FULLNAME)-running_xapp --network $($*_DCKR_FULLNAME)-running_network -e DBAAS_SERVICE_HOST=$($*_DCKR_FULLNAME)-running_redis $($*_DCKR_FULLNAME) /bin/bash
+
+docker-run_%: .docker-services-drun_%
+ docker run $($*_DCKR_R_OPTS) --name $($*_DCKR_FULLNAME)-running_xapp --network $($*_DCKR_FULLNAME)-running_network -e DBAAS_SERVICE_HOST=$($*_DCKR_FULLNAME)-running_redis $($*_DCKR_FULLNAME)
+
+docker-stop_%:
+ docker rm -f $($*_DCKR_FULLNAME)-running_xapp &> /dev/null || true
+ docker rm -f $($*_DCKR_FULLNAME)-running_redis &> /dev/null || true
+ docker network rm $($*_DCKR_FULLNAME)-running_network &> /dev/null || true
+
+docker-irun-stop_%: docker-irun_%
+ docker rm -f $($*_DCKR_FULLNAME)-running_xapp &> /dev/null || true
+ docker rm -f $($*_DCKR_FULLNAME)-running_redis &> /dev/null || true
+ docker network rm $($*_DCKR_FULLNAME)-running_network &> /dev/null || true
+
+docker-irun-mounted-stop_%: docker-irun-mounted_%
+ docker rm -f $($*_DCKR_FULLNAME)-running_xapp &> /dev/null || true
+ docker rm -f $($*_DCKR_FULLNAME)-running_redis &> /dev/null || true
+ docker network rm $($*_DCKR_FULLNAME)-running_network &> /dev/null || true
+
+docker-run-stop_%: docker-run_%
+ docker rm -f $($*_DCKR_FULLNAME)-running_xapp &> /dev/null || true
+ docker rm -f $($*_DCKR_FULLNAME)-running_redis &> /dev/null || true
+ docker network rm $($*_DCKR_FULLNAME)-running_network &> /dev/null || true
+
+docker-clean_%: docker-stop_%
docker rmi $($*_DCKR_FULLNAME) || true
docker-clean: DCKR_TARGETS:=
docker-clean: $$(DCKR_TARGETS)
+.SECONDEXPANSION:
+docker-stop: DCKR_TARGETS:=
+docker-stop: $$(DCKR_TARGETS)
+
endif
#------------------------------------------------------------------------------
$(DCKR_NAME)_DCKR_B_OPTS:=${DCKR_B_OPTS}
$(DCKR_NAME)_DCKR_B_OPTS:=$($(DCKR_NAME)_DCKR_B_OPTS) --network=host
-ifndef PACKAGEURL
+ifdef PACKAGEURL
$(DCKR_NAME)_DCKR_B_OPTS:=$($(DCKR_NAME)_DCKR_B_OPTS) --build-arg PACKAGEURL=${PACKAGEURL}
endif
-ifndef PACKAGEREPO
-$(DCKR_NAME)_DCKR_B_OPTS:=$($(DCKR_NAME)_DCKR_B_OPTS) --build-arg PACKAGEREPO=${PACKAGEREPO}
-endif
-
-ifndef BUILD_PREFIX
+ifdef BUILD_PREFIX
$(DCKR_NAME)_DCKR_B_OPTS:=$($(DCKR_NAME)_DCKR_B_OPTS) --build-arg BUILD_PREFIX=${BUILD_PREFIX}
endif
docker-clean: DCKR_TARGETS+=docker-clean_$(DCKR_NAME)
+docker-stop: DCKR_TARGETS+=docker-stop_$(DCKR_NAME)
+
#------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
-#ROOT_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
-
ifndef ROOT_DIR
$(error ROOT_DIR NOT DEFINED)
endif
-BUILD_DIR?=$(abspath $(ROOT_DIR)/build)
-CACHE_DIR?=$(abspath $(BUILD_DIR)/cache)
+ifndef CACHE_DIR
+$(error CACHE_DIR NOT DEFINED)
+endif
+
+#------------------------------------------------------------------------------
+#
+#------------------------------------------------------------------------------
+GO_CACHE_DIR?=$(abspath $(CACHE_DIR)/go)
#------------------------------------------------------------------------------
#
-#-------------------------------------------------------------------- ----------
+#------------------------------------------------------------------------------
ifndef MAKE_GO_TARGETS
MAKE_GO_TARGETS:=1
+.PHONY: FORCE go-build go-test go-test-fmt go-fmt go-clean
+
+FORCE:
+
+
GOOS=$(shell go env GOOS)
GOCMD=go
GOBUILD=$(GOCMD) build -a -installsuffix cgo
GOALLFILES:=$(shell find $(ROOT_DIR) -name '*.go')
GOMODFILES:=go.mod go.sum
-.PHONY: FORCE go-build go-test go-test-fmt go-fmt go-clean
-
-
-FORCE:
-
-$(CACHE_DIR)/%: $(GOFILES) $(GOMODFILES)
+.SECONDEXPANSION:
+$(GO_CACHE_DIR)/%: $(GOFILES) $(GOMODFILES) $$(BUILDDEPS)
@echo "Building:\t$*"
GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOBUILD) -o $@ ./$*
-$(CACHE_DIR)/%_test: $(GOALLFILES) $(GOMODFILES)
+.SECONDEXPANSION:
+$(GO_CACHE_DIR)/%_test: $(GOALLFILES) $(GOMODFILES) $$(BUILDDEPS) FORCE
@echo "Testing:\t$*"
GO111MODULE=on GO_ENABLED=0 GOOS=linux $(GOTEST) -coverprofile $(COVEROUT) -c -o $@ ./$*
test -e $@ && (eval $(TESTENV) $@ -test.coverprofile $(COVEROUT) || false) || true
.SECONDEXPANSION:
-go-build: XAPP_TARGETS:=
-go-build: $$(XAPP_TARGETS)
+go-build: GO_TARGETS:=
+go-build: $$(GO_TARGETS)
.SECONDEXPANSION:
-go-test: XAPP_TARGETS:=
-go-test: go-clean $$(XAPP_TARGETS)
+go-test: GO_TARGETS:=
+go-test: $$(GO_TARGETS)
go-test-fmt: $(GOFILES)
@(RESULT="$$(gofmt -l $^)"; test -z "$${RESULT}" || (echo -e "gofmt failed:\n$${RESULT}" && false) )
go-fmt: $(GOFILES)
gofmt -w -s $^
-go-clean: XAPP_TARGETS:=
+go-mod-tidy: FORCE
+ GO111MODULE=on go mod tidy
+
+go-mod-download: FORCE
+ GO111MODULE=on go mod download
+
+go-clean: GO_TARGETS:=
go-clean:
@echo " > Cleaning build cache"
- @-rm -rf $(XAPP_TARGETS)* 2> /dev/null
+ @-rm -rf $(GO_TARGETS)* 2> /dev/null
go clean 2> /dev/null
#
#-------------------------------------------------------------------- ----------
-$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: COVEROUT:=$(abspath $(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_cover.out)
-$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: COVERHTML:=$(abspath $(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_cover.html)
-$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: TESTENV:=$(XAPP_TESTENV)
+$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME): BUILDDEPS:=$(XAPP_BUILDDEPS)
+
+
+$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: BUILDDEPS:=$(XAPP_BUILDDEPS)
+$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: COVEROUT:=$(abspath $(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_cover.out)
+$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: COVERHTML:=$(abspath $(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_cover.html)
+$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test: TESTENV:=$(XAPP_TESTENV)
-go-build: XAPP_TARGETS+=$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)
-go-test: XAPP_TARGETS+=$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test
-go-clean: XAPP_TARGETS+=$(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME) $(CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test
+go-build: GO_TARGETS+=$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)
+go-test: GO_TARGETS+=$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test
+go-clean: GO_TARGETS+=$(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME) $(GO_CACHE_DIR)/$(XAPP_ROOT)/$(XAPP_NAME)_test
"errors"
"fmt"
"github.com/spf13/viper"
+ "github.com/valyala/fastjson"
"github.com/xeipuuv/gojsonschema"
"io/ioutil"
"log"
Data: r.Configuration,
}
- cmJson, err := json.Marshal(c)
+ cmJson, err := json.Marshal(c.Data)
if err != nil {
log.Println("Config marshalling failed: ", err)
return
return
}
+func (cm *ConfigMap) GetConfigMap(m XappDeploy, c *interface{}) (err error) {
+ if m.ConfigName == "" {
+ m.ConfigName = m.Name + "-appconfig"
+ }
+ return cm.ReadConfigMap(m.ConfigName, m.Namespace, c)
+}
+
func (cm *ConfigMap) CreateConfigMap(r XAppConfig) (errList []CMError, err error) {
if errList, err = cm.Validate(r); err != nil {
return
func (cm *ConfigMap) GetMessages(name string) (msgs MessageTypes) {
log.Println("Fetching tx/rx messages for: ", name)
+
+ args := fmt.Sprintf("get configmap -o jsonpath='{.data.config-file\\.json}' -n ricxapp %s-appconfig", name)
+ out, err := KubectlExec(args)
+ if err != nil {
+ return
+ }
+
+ var p fastjson.Parser
+ v, err := p.Parse(string(out))
+ if err != nil {
+ log.Printf("fastjson.Parser for '%s' failed: %v", name, err)
+ return
+ }
+
+ for _, m := range v.GetArray("rmr", "txMessages") {
+ msgs.TxMessages = append(msgs.TxMessages, strings.Trim(m.String(), `"`))
+ }
+ for _, m := range v.GetArray("rmr", "rxMessages") {
+ msgs.RxMessages = append(msgs.RxMessages, strings.Trim(m.String(), `"`))
+ }
+
return
}
helm-repo/reporter 0.0.1 1.0 Helm Chart for Reporting xAPP
helm-repo/uemgr 0.0.1 1.0 Helm Chart for Nokia uemgr xAPP
`
+
+var kubectlConfigmapOutput = `
+{
+ "local": {
+ "host": ":8080"
+ },
+ "logger": {
+ "level": 3
+ },
+ "rmr": {
+ "protPort": "tcp:4560",
+ "maxSize": 2072,
+ "numWorkers": 1,
+ "txMessages": ["RIC_X2_LOAD_INFORMATION"],
+ "rxMessages": ["RIC_X2_LOAD_INFORMATION"]
+ },
+ "db": {
+ "namespace": "ricxapp",
+ "host": "dbaas",
+ "port": 6379
+ }
+}
+`
+
type ConfigSample struct {
Level int
Host string
// Test cases
func TestGetMessages(t *testing.T) {
cm := ConfigMap{}
- expectedMsgs := MessageTypes{}
+ expectedMsgs := MessageTypes{
+ TxMessages: []string{"RIC_X2_LOAD_INFORMATION"},
+ RxMessages: []string{"RIC_X2_LOAD_INFORMATION"},
+ }
+
+ KubectlExec = func(args string) (out []byte, err error) {
+ return []byte(kubectlConfigmapOutput), nil
+ }
- if !reflect.DeepEqual(cm.GetMessages("dummy-xapp"), expectedMsgs) {
- t.Errorf("TestGetMessages failed!")
+ result := cm.GetMessages("dummy-xapp")
+ if !reflect.DeepEqual(result, expectedMsgs) {
+ t.Errorf("TestGetMessages failed: expected: %v, got: %v", expectedMsgs, result)
}
}
}
var cm interface{}
- if err = h.cm.ReadConfigMap(m.Name, m.Namespace, &cm); err != nil {
+ m.Namespace = getNamespace(m.Namespace)
+
+ if err = h.cm.GetConfigMap(m, &cm); err != nil {
out, err = h.Run(getInstallArgs(m, false))
if err != nil {
return
}
func getInstallArgs(x XappDeploy, cmOverride bool) (args string) {
- x.Namespace = getNamespace(x.Namespace)
args = args + " --namespace=" + x.Namespace
if x.ImageRepo != "" {
- args = args + " --set image.repository=" + x.ImageRepo
+ args = args + " --set global.repository=" + x.ImageRepo
}
if x.ServiceName != "" {
- args = args + " --set service.name=" + x.ServiceName
+ args = args + " --set ricapp.service.name=" + x.ServiceName
}
if x.Hostname != "" {
- args = args + " --set hostname=" + x.Hostname
+ args = args + " --set ricapp.hostname=" + x.Hostname
}
if cmOverride == true {
- args = args + " --set appconfig.override=true"
+ args = args + " --set ricapp.appconfig.override=" + x.Name + "-appconfig"
}
rname := viper.GetString("helm.repo-name")
type ConfigMapper interface {
UploadConfig() (cfg []XAppConfig)
+ GetConfigMap(m XappDeploy, c *interface{}) (err error)
CreateConfigMap(r XAppConfig) (errList []CMError, err error)
UpdateConfigMap(r XAppConfig) (errList []CMError, err error)
DeleteConfigMap(r XAppConfig) (cm interface{}, err error)
}
type MessageTypes struct {
- TxMessages []string `yaml:"txMessages"`
- RxMessages []string `yaml:"rxMessages"`
+ TxMessages []string `json:"txMessages"`
+ RxMessages []string `json:"rxMessages"`
}
type EventType string
github.com/orcaman/concurrent-map v0.0.0-20190314100340-2693aad1ed75
github.com/segmentio/ksuid v1.0.2
github.com/spf13/viper v1.3.2
+ github.com/valyala/fastjson v1.4.1
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.1.0
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE=
+github.com/valyala/fastjson v1.4.1/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=