From 09edf28fd47faf808e053d6ede06315c3926fa45 Mon Sep 17 00:00:00 2001 From: Tommy Carpenter Date: Tue, 11 Jun 2019 09:10:23 -0400 Subject: [PATCH] Move integration tests to k8s Change-Id: Ia78a484e9f9eea4ace1ef6fa0d8075b872b8f83b Signed-off-by: Tommy Carpenter --- .gitignore | 1 + docs/developer-guide.rst | 2 +- docs/index.rst | 37 +++++++------ .../a1mediator}/.helmignore | 0 .../a1mediator}/Chart.yaml | 0 .../a1mediator}/files/ricmanifest.json | 0 .../a1mediator}/files/rmr_string_int_mapping.txt | 0 .../a1mediator}/templates/_helpers.tpl | 0 .../a1mediator}/templates/config.yaml | 4 +- .../a1mediator}/templates/deployment.yaml | 0 .../a1mediator}/templates/helper.yaml | 0 .../a1mediator}/templates/ingress.yaml | 0 .../a1mediator}/templates/secrets.yaml | 0 .../a1mediator}/templates/service.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../a1mediator}/values.yaml | 5 +- integration_tests/delayreceiver/.helmignore | 22 ++++++++ integration_tests/delayreceiver/Chart.yaml | 5 ++ .../delayreceiver/templates/_helpers.tpl | 45 ++++++++++++++++ .../delayreceiver/templates/config.yaml | 11 ++++ .../delayreceiver/templates/deployment.yaml | 46 ++++++++++++++++ .../delayreceiver/templates/service.yaml | 15 ++++++ integration_tests/delayreceiver/values.yaml | 42 +++++++++++++++ integration_tests/docker-compose-only-tests.yml | 38 ------------- integration_tests/docker-compose.yml | 63 ---------------------- integration_tests/portforward.sh | 3 ++ integration_tests/test_docker.rt | 6 --- integration_tests/testreceiver/.helmignore | 22 ++++++++ integration_tests/testreceiver/Chart.yaml | 5 ++ .../testreceiver/templates/_helpers.tpl | 45 ++++++++++++++++ .../testreceiver/templates/config.yaml | 11 ++++ .../testreceiver/templates/deployment.yaml | 32 +++++++++++ .../testreceiver/templates/service.yaml | 15 ++++++ integration_tests/testreceiver/values.yaml | 42 +++++++++++++++ tox-integration.ini | 28 +++++++--- 35 files changed, 410 insertions(+), 135 deletions(-) rename {a1mediator => integration_tests/a1mediator}/.helmignore (100%) rename {a1mediator => integration_tests/a1mediator}/Chart.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/files/ricmanifest.json (100%) rename {a1mediator => integration_tests/a1mediator}/files/rmr_string_int_mapping.txt (100%) rename {a1mediator => integration_tests/a1mediator}/templates/_helpers.tpl (100%) rename {a1mediator => integration_tests/a1mediator}/templates/config.yaml (83%) rename {a1mediator => integration_tests/a1mediator}/templates/deployment.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/templates/helper.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/templates/ingress.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/templates/secrets.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/templates/service.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/templates/tests/test-connection.yaml (100%) rename {a1mediator => integration_tests/a1mediator}/values.yaml (95%) create mode 100644 integration_tests/delayreceiver/.helmignore create mode 100644 integration_tests/delayreceiver/Chart.yaml create mode 100644 integration_tests/delayreceiver/templates/_helpers.tpl create mode 100644 integration_tests/delayreceiver/templates/config.yaml create mode 100644 integration_tests/delayreceiver/templates/deployment.yaml create mode 100644 integration_tests/delayreceiver/templates/service.yaml create mode 100644 integration_tests/delayreceiver/values.yaml delete mode 100644 integration_tests/docker-compose-only-tests.yml delete mode 100644 integration_tests/docker-compose.yml create mode 100755 integration_tests/portforward.sh delete mode 100644 integration_tests/test_docker.rt create mode 100644 integration_tests/testreceiver/.helmignore create mode 100644 integration_tests/testreceiver/Chart.yaml create mode 100644 integration_tests/testreceiver/templates/_helpers.tpl create mode 100644 integration_tests/testreceiver/templates/config.yaml create mode 100644 integration_tests/testreceiver/templates/deployment.yaml create mode 100644 integration_tests/testreceiver/templates/service.yaml create mode 100644 integration_tests/testreceiver/values.yaml diff --git a/.gitignore b/.gitignore index 2cb6a1c..542e654 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.log NOTES.txt .pytest_cache/ xunit-results.xml diff --git a/docs/developer-guide.rst b/docs/developer-guide.rst index 9dea8dd..f9a95cc 100644 --- a/docs/developer-guide.rst +++ b/docs/developer-guide.rst @@ -76,7 +76,7 @@ Running locally Testing locally =============== -There are also two test receivers in ``localtests`` you can run locally. +There are also two test receivers in ``integration_tests`` you can run locally. The first is meant to be used with the ``control_admission`` policy (that comes in test fixture ric manifest): diff --git a/docs/index.rst b/docs/index.rst index 19bce13..26a89e0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -39,14 +39,28 @@ Integration testing =================== This tests A1’s external API with two test receivers. Note, this -currently depends on docker-compose, meaning you cannot run this if -docker-compose is not installed. Note2: this is not fast. It builds the -containers and launches requests against the API so it takes time. +currently depends on helm+k8s, meaning you cannot run this if +this is not installed. +If you've never run the integration tests before, build the test receiver +:: + + cd integration_tests + docker build --no-cache -t testreceiver:latest . + +Else, from the root, :: tox -c tox-integration.ini +This script: +1. Deploys 3 helm charts into a local kubernetes installation +2. Port forwards a pod ClusterIP to localhost +3. Uses “tavern” to run some tests against the server +4. Barrages the server with apache bench +5. Tears everything down + + Running ======= @@ -66,22 +80,13 @@ returns a 503. The default is ``4``. K8S --- -The helm chart is in the folder `a1mediator`. - -There are two files in `a1mediator/files` that should be replaced with the "real" files for deployment. The ones included there, and referenced in the configmap, are only samples. To deploy A1 correctly, make sure these files are correct. +The "real" helm chart for A1 is in the LF it/dep repo. That repo holds all of the helm charts for the RIC platform. There is a helm chart in `integration_tests` here for running the integration tests as discussed above. -:: - - helm install --devel a1mediator/ --name a1 --set imageCredentials.username=xxx --set imageCredentials.password=xxx - -The username and password here are the credentials to the registry defined in `a1mediator/values.yaml`. Currently this is the LF docker registry. - -Docker ------- +Local Docker +------------ building ~~~~~~~~ - :: docker build --no-cache -t a1:X.Y.Z . @@ -91,8 +96,6 @@ building running ~~~~~~~ -(TODO: this will be enhanced with Helm.) - :: docker run -dt -p 10000:10000 -v /path/to/localrt:/opt/route/local.rt -v /path/to/ricmanifest:/opt/ricmanifest.json a1:X.Y.Z -v diff --git a/a1mediator/.helmignore b/integration_tests/a1mediator/.helmignore similarity index 100% rename from a1mediator/.helmignore rename to integration_tests/a1mediator/.helmignore diff --git a/a1mediator/Chart.yaml b/integration_tests/a1mediator/Chart.yaml similarity index 100% rename from a1mediator/Chart.yaml rename to integration_tests/a1mediator/Chart.yaml diff --git a/a1mediator/files/ricmanifest.json b/integration_tests/a1mediator/files/ricmanifest.json similarity index 100% rename from a1mediator/files/ricmanifest.json rename to integration_tests/a1mediator/files/ricmanifest.json diff --git a/a1mediator/files/rmr_string_int_mapping.txt b/integration_tests/a1mediator/files/rmr_string_int_mapping.txt similarity index 100% rename from a1mediator/files/rmr_string_int_mapping.txt rename to integration_tests/a1mediator/files/rmr_string_int_mapping.txt diff --git a/a1mediator/templates/_helpers.tpl b/integration_tests/a1mediator/templates/_helpers.tpl similarity index 100% rename from a1mediator/templates/_helpers.tpl rename to integration_tests/a1mediator/templates/_helpers.tpl diff --git a/a1mediator/templates/config.yaml b/integration_tests/a1mediator/templates/config.yaml similarity index 83% rename from a1mediator/templates/config.yaml rename to integration_tests/a1mediator/templates/config.yaml index 05f1630..d32e7f1 100644 --- a/a1mediator/templates/config.yaml +++ b/integration_tests/a1mediator/templates/config.yaml @@ -5,8 +5,8 @@ metadata: data: local.rt: | newrt|start - rte|10000|rmr_delay_receiver:4563 - rte|20000|rmr_receiver:4560 + rte|20000|testreceiverrmrservice:4560 + rte|10000|delayreceiverrmrservice:4563 rte|10001|{{ .Values.rmrservice.name }}:{{ .Values.rmrservice.port }} rte|20001|{{ .Values.rmrservice.name }}:{{ .Values.rmrservice.port }} newrt|end diff --git a/a1mediator/templates/deployment.yaml b/integration_tests/a1mediator/templates/deployment.yaml similarity index 100% rename from a1mediator/templates/deployment.yaml rename to integration_tests/a1mediator/templates/deployment.yaml diff --git a/a1mediator/templates/helper.yaml b/integration_tests/a1mediator/templates/helper.yaml similarity index 100% rename from a1mediator/templates/helper.yaml rename to integration_tests/a1mediator/templates/helper.yaml diff --git a/a1mediator/templates/ingress.yaml b/integration_tests/a1mediator/templates/ingress.yaml similarity index 100% rename from a1mediator/templates/ingress.yaml rename to integration_tests/a1mediator/templates/ingress.yaml diff --git a/a1mediator/templates/secrets.yaml b/integration_tests/a1mediator/templates/secrets.yaml similarity index 100% rename from a1mediator/templates/secrets.yaml rename to integration_tests/a1mediator/templates/secrets.yaml diff --git a/a1mediator/templates/service.yaml b/integration_tests/a1mediator/templates/service.yaml similarity index 100% rename from a1mediator/templates/service.yaml rename to integration_tests/a1mediator/templates/service.yaml diff --git a/a1mediator/templates/tests/test-connection.yaml b/integration_tests/a1mediator/templates/tests/test-connection.yaml similarity index 100% rename from a1mediator/templates/tests/test-connection.yaml rename to integration_tests/a1mediator/templates/tests/test-connection.yaml diff --git a/a1mediator/values.yaml b/integration_tests/a1mediator/values.yaml similarity index 95% rename from a1mediator/values.yaml rename to integration_tests/a1mediator/values.yaml index 7c9f1f3..5ceefb0 100644 --- a/a1mediator/values.yaml +++ b/integration_tests/a1mediator/values.yaml @@ -17,18 +17,19 @@ imageCredentials: # This is the service for A1's external facing HTTP API httpservice: + name: a1httpservice port: 10000 # This is hardcoded in a1, probably dangerous to change type: ClusterIP # This is the service for rmr between A1 and the xapps rmrservice: - name: rmrservice + name: a1rmrservice port: 4562 # This is hardcoded in a1, probably dangerous to change type: ClusterIP # This is the service for the "hidden" port 4561 that rmr listens on for route manager rmrrtemgrservice: - name: rmrrtemgrservice + name: a1rmrrtemgrservice port: 4561 # This is hardcoded in rmr, probably dangerous to change type: ClusterIP diff --git a/integration_tests/delayreceiver/.helmignore b/integration_tests/delayreceiver/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/integration_tests/delayreceiver/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/integration_tests/delayreceiver/Chart.yaml b/integration_tests/delayreceiver/Chart.yaml new file mode 100644 index 0000000..8ad2c2b --- /dev/null +++ b/integration_tests/delayreceiver/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Test receiver for a1 integration tests +name: delayreceiver +version: 0.1.0 diff --git a/integration_tests/delayreceiver/templates/_helpers.tpl b/integration_tests/delayreceiver/templates/_helpers.tpl new file mode 100644 index 0000000..ce5f322 --- /dev/null +++ b/integration_tests/delayreceiver/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "delayreceiver.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "delayreceiver.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "delayreceiver.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "delayreceiver.labels" -}} +app.kubernetes.io/name: {{ include "delayreceiver.name" . }} +helm.sh/chart: {{ include "delayreceiver.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/integration_tests/delayreceiver/templates/config.yaml b/integration_tests/delayreceiver/templates/config.yaml new file mode 100644 index 0000000..a42f325 --- /dev/null +++ b/integration_tests/delayreceiver/templates/config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: delayreceiverconf +data: + local.rt: | + newrt|start + rte|10000|{{ .Values.rmrservice.name }}:{{ .Values.rmrservice.port }} + rte|10001|a1rmrservice:4562 + newrt|end + diff --git a/integration_tests/delayreceiver/templates/deployment.yaml b/integration_tests/delayreceiver/templates/deployment.yaml new file mode 100644 index 0000000..cae53c4 --- /dev/null +++ b/integration_tests/delayreceiver/templates/deployment.yaml @@ -0,0 +1,46 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "delayreceiver.fullname" . }} + labels: +{{ include "delayreceiver.labels" . | indent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: {{ include "delayreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "delayreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: delayreceiver + image: testreceiver:latest + imagePullPolicy: Never + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: delayreceiverconf + mountPath: /opt/route/local.rt + subPath: local.rt + env: + - name: RMR_RCV_RETRY_INTERVAL + value: "500" + - name: RMR_RETRY_TIMES + value: "10" + - name: TEST_RCV_PORT + value: "{{ .Values.rmrservice.port }}" + - name: TEST_RCV_RETURN_MINT + value: "10001" + - name: TEST_RCV_SEC_DELAY + value: "5" + - name: TEST_RCV_RETURN_PAYLOAD + value: '{"ACK_FROM": "DELAYED_TEST", "status": "SUCCESS"}' + + volumes: + - name: "delayreceiverconf" + configMap: + name: "delayreceiverconf" diff --git a/integration_tests/delayreceiver/templates/service.yaml b/integration_tests/delayreceiver/templates/service.yaml new file mode 100644 index 0000000..04a5bfb --- /dev/null +++ b/integration_tests/delayreceiver/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.rmrservice.name }} + labels: +{{ include "delayreceiver.labels" . | indent 4 }} +spec: + type: {{ .Values.rmrservice.type }} + ports: + - port: {{ .Values.rmrservice.port }} + targetPort: {{ .Values.rmrservice.port }} + protocol: TCP + selector: + app.kubernetes.io/name: {{ include "delayreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/integration_tests/delayreceiver/values.yaml b/integration_tests/delayreceiver/values.yaml new file mode 100644 index 0000000..1655808 --- /dev/null +++ b/integration_tests/delayreceiver/values.yaml @@ -0,0 +1,42 @@ +# Default values for delayreceiver. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +rmrservice: + name: delayreceiverrmrservice + type: ClusterIP + port: 4563 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/integration_tests/docker-compose-only-tests.yml b/integration_tests/docker-compose-only-tests.yml deleted file mode 100644 index 34facae..0000000 --- a/integration_tests/docker-compose-only-tests.yml +++ /dev/null @@ -1,38 +0,0 @@ -# ================================================================================== -# Copyright (c) 2019 Nokia -# Copyright (c) 2018-2019 AT&T Intellectual Property. -# -# 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. -# ================================================================================== -version: '3' -services: - - rmr_receiver: - build: . - hostname: "rmr_receiver" - volumes: - - ./test_docker.rt:/opt/route/local.rt - - rmr_delay_receiver: - build: . - hostname: "rmr_delay_receiver" - volumes: - - ./test_docker.rt:/opt/route/local.rt - environment: - # https://github.com/docker/compose/issues/3878 - RMR_RCV_RETRY_INTERVAL: 500 - RMR_RETRY_TIMES: 10 - TEST_RCV_PORT: 4563 - TEST_RCV_RETURN_MINT: 10001 - TEST_RCV_SEC_DELAY: 5 - TEST_RCV_RETURN_PAYLOAD: '{"ACK_FROM": "DELAYED_TEST", "status": "SUCCESS"}' diff --git a/integration_tests/docker-compose.yml b/integration_tests/docker-compose.yml deleted file mode 100644 index 0deec85..0000000 --- a/integration_tests/docker-compose.yml +++ /dev/null @@ -1,63 +0,0 @@ -# ================================================================================== -# Copyright (c) 2019 Nokia -# Copyright (c) 2018-2019 AT&T Intellectual Property. -# -# 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. -# ================================================================================== -version: '3' -services: - - rmr_receiver: - build: . - hostname: "rmr_receiver" - volumes: - - ./test_docker.rt:/opt/route/local.rt - - rmr_delay_receiver: - build: . - hostname: "rmr_delay_receiver" - volumes: - - ./test_docker.rt:/opt/route/local.rt - environment: - # https://github.com/docker/compose/issues/3878 - RMR_RCV_RETRY_INTERVAL: 500 - RMR_RETRY_TIMES: 10 - TEST_RCV_PORT: 4563 - TEST_RCV_RETURN_MINT: 10001 - TEST_RCV_SEC_DELAY: 5 - TEST_RCV_RETURN_PAYLOAD: '{"ACK_FROM": "DELAYED_TEST", "status": "SUCCESS"}' - -# bombarder: -# build: -# context: . -# dockerfile: Dockerfile-Bombard -# hostname: "bombarder" -# volumes: -# - /tmp/local.rt:/opt/route/local.rt -# environment: -# BOMBARD_DELAY_MS: 100 -# - a1: - image: a1:latest - build: - context: .. - hostname: "a1" - volumes: - - ./test_docker.rt:/opt/route/local.rt - - ./../tests/fixtures/ricmanifest.json:/opt/ricmanifest.json - - ./../tests/fixtures/rmr_string_int_mapping.txt:/opt/rmr_string_int_mapping.txt - ports: - - "10000:10000" - environment: - RMR_RCV_RETRY_INTERVAL: 500 - RMR_RETRY_TIMES: 20 diff --git a/integration_tests/portforward.sh b/integration_tests/portforward.sh new file mode 100755 index 0000000..09d2a8e --- /dev/null +++ b/integration_tests/portforward.sh @@ -0,0 +1,3 @@ +#!/bin/bash +kubectl port-forward $(kubectl get pods --namespace default -l "app.kubernetes.io/name=a1mediator,app.kubernetes.io/instance=a1" -o jsonpath="{.items[0].metadata.name}") 10000:10000 2>&1 > forward.log & + diff --git a/integration_tests/test_docker.rt b/integration_tests/test_docker.rt deleted file mode 100644 index 2173707..0000000 --- a/integration_tests/test_docker.rt +++ /dev/null @@ -1,6 +0,0 @@ -newrt|start -rte|10000|rmr_delay_receiver:4563 -rte|20000|rmr_receiver:4560 -rte|10001|a1:4562 -rte|20001|a1:4562 -newrt|end diff --git a/integration_tests/testreceiver/.helmignore b/integration_tests/testreceiver/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/integration_tests/testreceiver/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/integration_tests/testreceiver/Chart.yaml b/integration_tests/testreceiver/Chart.yaml new file mode 100644 index 0000000..917669d --- /dev/null +++ b/integration_tests/testreceiver/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Test receiver for a1 integration tests +name: testreceiver +version: 0.1.0 diff --git a/integration_tests/testreceiver/templates/_helpers.tpl b/integration_tests/testreceiver/templates/_helpers.tpl new file mode 100644 index 0000000..f35130c --- /dev/null +++ b/integration_tests/testreceiver/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "testreceiver.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "testreceiver.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "testreceiver.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "testreceiver.labels" -}} +app.kubernetes.io/name: {{ include "testreceiver.name" . }} +helm.sh/chart: {{ include "testreceiver.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/integration_tests/testreceiver/templates/config.yaml b/integration_tests/testreceiver/templates/config.yaml new file mode 100644 index 0000000..36a379b --- /dev/null +++ b/integration_tests/testreceiver/templates/config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: testreceiverconf +data: + local.rt: | + newrt|start + rte|20000|{{ .Values.rmrservice.name }}:{{ .Values.rmrservice.port }} + rte|20001|a1rmrservice:4562 + newrt|end + diff --git a/integration_tests/testreceiver/templates/deployment.yaml b/integration_tests/testreceiver/templates/deployment.yaml new file mode 100644 index 0000000..2d49f6e --- /dev/null +++ b/integration_tests/testreceiver/templates/deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "testreceiver.fullname" . }} + labels: +{{ include "testreceiver.labels" . | indent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: {{ include "testreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "testreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: testreceiver + image: testreceiver:latest + imagePullPolicy: Never + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: testreceiverconf + mountPath: /opt/route/local.rt + subPath: local.rt + volumes: + - name: "testreceiverconf" + configMap: + name: "testreceiverconf" diff --git a/integration_tests/testreceiver/templates/service.yaml b/integration_tests/testreceiver/templates/service.yaml new file mode 100644 index 0000000..7c32ff9 --- /dev/null +++ b/integration_tests/testreceiver/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.rmrservice.name }} + labels: +{{ include "testreceiver.labels" . | indent 4 }} +spec: + type: {{ .Values.rmrservice.type }} + ports: + - port: {{ .Values.rmrservice.port }} + targetPort: {{ .Values.rmrservice.port }} + protocol: TCP + selector: + app.kubernetes.io/name: {{ include "testreceiver.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/integration_tests/testreceiver/values.yaml b/integration_tests/testreceiver/values.yaml new file mode 100644 index 0000000..e0b8f40 --- /dev/null +++ b/integration_tests/testreceiver/values.yaml @@ -0,0 +1,42 @@ +# Default values for testreceiver. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +rmrservice: + name: testreceiverrmrservice + type: ClusterIP + port: 4560 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/tox-integration.ini b/tox-integration.ini index 539da92..fb005a0 100644 --- a/tox-integration.ini +++ b/tox-integration.ini @@ -20,18 +20,34 @@ envlist = int [testenv:int] whitelist_externals= sleep - docker-compose + helm ab + echo + pkill +passenv = * deps = - pytest-xdist tavern changedir=integration_tests commands_pre= - docker-compose up --build -d + helm install --devel testreceiver -n testreceiver + helm install --devel delayreceiver -n delayreceiver + helm install --devel a1mediator/ -n a1 + sleep 10 + ./portforward.sh sleep 2 commands= -# helm lint a1mediator/ - pytest -n 2 + echo "linting" + helm lint a1mediator/ + echo "running tavern" + pytest + echo "running ab" ab -n 100 -c 10 -u putdata -T application/json http://localhost:10000/ric/policies/control_admission_time commands_post= - docker-compose down + helm delete testreceiver + helm del --purge testreceiver + helm delete delayreceiver + helm del --purge delayreceiver + helm delete a1 + helm del --purge a1 + pkill -9 kubectl + sleep 10 -- 2.16.6