diff --git a/.gitignore b/.gitignore index 4ef4c9e0b511464b549c871721d2cf60d71ff290..04c0ab108b39f4eacb1bf0b7c72a8a101ef11275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.vscode +venv build .DS_Store *.swp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8866e6190b95395d3b7c1a734eb392bb7a176ce9..bf760c4ab1eb99e2a94073e2ca188592226c22d8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ stages: - build_3 - build_4 - build_5 -- push +# - push - test - publish - cleanup_build @@ -29,10 +29,11 @@ build_tango-builder: retry: 2 stage: build_0 tags: - - shell + - k8srunner script: - cd docker/tango/tango-builder - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-builder/**/* @@ -41,7 +42,7 @@ build_deploy_image: retry: 2 stage: build_0 tags: - - shell + - k8srunner script: - cd docker/deploy - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build @@ -54,10 +55,11 @@ build_dependencies: retry: 2 stage: build_1 tags: - - shell + - k8srunner script: - cd docker/tango/tango-dependencies - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -66,10 +68,11 @@ build_tango-db: retry: 2 stage: build_1 tags: - - shell + - k8srunner script: - cd docker/tango/tango-db - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-db/**/* @@ -78,10 +81,11 @@ build_tango-cpp: retry: 2 stage: build_2 tags: - - shell + - k8srunner script: - cd docker/tango/tango-cpp - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -91,10 +95,11 @@ build_tango-java: retry: 2 stage: build_2 tags: - - shell + - k8srunner script: - cd docker/tango/tango-java - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -104,10 +109,11 @@ build_tango-rest: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-rest - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -118,10 +124,11 @@ build_tango-dsconfig: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-dsconfig - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -132,10 +139,11 @@ build_ska-python-buildenv: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/ska-python-buildenv - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -146,10 +154,11 @@ build_tango-pogo: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-pogo - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -160,10 +169,11 @@ build_tango-starter: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-starter - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -174,10 +184,11 @@ build_tango-libtango: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-libtango - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -188,10 +199,11 @@ build_tango-jive: retry: 2 stage: build_3 tags: - - shell + - k8srunner script: - cd docker/tango/tango-jive - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -202,10 +214,11 @@ build_ska-python-runtime: retry: 2 stage: build_4 tags: - - shell + - k8srunner script: - cd docker/tango/ska-python-runtime - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -217,10 +230,11 @@ build_tango-admin: retry: 2 stage: build_4 tags: - - shell + - k8srunner script: - cd docker/tango/tango-admin - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -232,10 +246,11 @@ build_tango-databaseds: retry: 2 stage: build_4 tags: - - shell + - k8srunner script: - cd docker/tango/tango-databaseds - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -247,10 +262,11 @@ build_tango-test: retry: 2 stage: build_4 tags: - - shell + - k8srunner script: - cd docker/tango/tango-test - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -262,10 +278,11 @@ build_tango-itango: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/tango-itango - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -278,10 +295,11 @@ build_tango-vscode: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/tango-vscode - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -294,10 +312,11 @@ build_tango-vnc: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/tango-vnc - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -308,10 +327,11 @@ build_tango-pytango: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/tango-pytango - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-dependencies/**/* @@ -324,10 +344,11 @@ build_tango-archiver: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/tango-archiver - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-archiver/**/* @@ -336,10 +357,11 @@ build_mariadb_hdbpp: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/mariadb_hdbpp - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-archiver/**/* @@ -350,120 +372,22 @@ build_hdbpp_viewer: retry: 2 stage: build_5 tags: - - shell + - k8srunner script: - cd docker/tango/hdbpp_viewer - make DOCKER_BUILD_ARGS="--no-cache" DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST build + - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push only: changes: - docker/tango/tango-archiver/**/* - docker/tango/hdbpp_viewer/**/* - docker/tango/mariadb_hdbpp/**/* -test-framework-tango-db: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-db build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-db test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-framework-tango-cpp: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-cpp build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-cpp test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-framework-tango-itango: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-itango build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-itango test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-framework-tango-rest: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-rest build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-rest test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-framework-ska-python-buildenv: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/ska-python-buildenv build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/ska-python-buildenv test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-framework-tango-archiver: - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-archiver build - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST -C docker/tango/tango-archiver test | tee .public/result.txt - - mv .public public - artifacts: - paths: - - public - -test-all: - when: manual - retry: 2 - stage: test - tags: - - shell - script: - - mkdir .public - - cd docker - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST test | tee ../.public/result.txt - - mv ../.public ../public - artifacts: - paths: - - public - test-chart: stage: test tags: - - docker-executor - image: nexus.engageska-portugal.pt/ska-docker/deploy:0.4.2 + - k8srunner + image: nexus.engageska-portugal.pt/ska-docker/deploy:0.4.3 script: - export KUBE_NAMESPACE="ci-ska-docker-$CI_COMMIT_SHORT_SHA" - cd charts/ @@ -486,13 +410,13 @@ test-chart: reports: junit: charts/build/report.xml -push: - stage: push - tags: - - shell - script: - - cd docker - - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push +# push: +# stage: push +# tags: +# - shell +# script: +# - cd docker +# - make DOCKER_REGISTRY_USER=$DOCKER_REGISTRY_FOLDER DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST push variables: CHARTS_TO_PUBLISH: tango-util tango-base archiver diff --git a/charts/Makefile b/charts/Makefile index d73f4e2e234c6225633fbaca15eabdb80232fd15..cf23395b9c3097af1f3d324df373557157cbbd17 100644 --- a/charts/Makefile +++ b/charts/Makefile @@ -5,6 +5,7 @@ HELM_HOST ?= https://nexus.engageska-portugal.pt## helm host url https MINIKUBE ?= true## Minikube or not MARK ?= all IMAGE_TO_TEST ?= nexus.engageska-portugal.pt/ska-docker/tango-vscode:0.2.7## docker image that will be run for testing purpose +# IMAGE_TO_TEST ?= nexus.engageska-portugal.pt/ska-docker/tango-itango:9.3.2.1## docker image that will be run for testing purpose TEST_RUNNER = test-makefile-runner-$(CI_JOB_ID)-$(KUBE_NAMESPACE)-$(RELEASE_NAME)##name of the pod running the k8s_tests TANGO_HOST=$(shell helm get values ${RELEASE_NAME} -a -n ${KUBE_NAMESPACE} | grep tango_host | head -1 | cut -d':' -f2 | cut -d' ' -f2):10000 CHARTS ?= tango-util tango-base archiver ska-docker## list of charts to be published on gitlab -- umbrella charts for testing purpose @@ -132,6 +133,7 @@ k8s_test = tar -c ../post-deployment/ | \ # clean up the run to completion container # exit the saved status test: ## test the application on K8s + cp tango-base/values.yaml ../post-deployment/tango_values.yaml $(call k8s_test,test); \ status=$$?; \ rm -fr build; \ @@ -139,6 +141,8 @@ test: ## test the application on K8s perl -ne 'BEGIN {$$on=0;}; if (index($$_, "~~~~BOUNDARY~~~~")!=-1){$$on+=1;next;}; print if $$on % 2;' | \ base64 -d | tar -xzf -; \ kubectl --namespace $(KUBE_NAMESPACE) delete pod $(TEST_RUNNER); \ + rm ../post-deployment/tango_values.yaml; \ + echo "Status set at \"$$status\" in charts/Makefile test target"; \ exit $$status show: diff --git a/docker-compose/.env b/docker-compose/.env deleted file mode 100644 index bf415f70a3466cd1dcdf87437e8d4e97758f6087..0000000000000000000000000000000000000000 --- a/docker-compose/.env +++ /dev/null @@ -1,2 +0,0 @@ -DOCKER_REGISTRY_HOST=nexus.engageska-portugal.pt -DOCKER_REGISTRY_USER=ska-docker diff --git a/docker-compose/Makefile b/docker-compose/Makefile deleted file mode 100644 index fd09bfb4aeb1e51704e5f3f8ecb0d0d0e26b9fa4..0000000000000000000000000000000000000000 --- a/docker-compose/Makefile +++ /dev/null @@ -1,122 +0,0 @@ -# Set dir of Makefile to a variable to use later -MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST))) -BASEDIR := $(notdir $(patsubst %/,%,$(dir $(MAKEPATH)))) - -COMPOSE_FILES := $(wildcard *.yml) -COMPOSE_FILE_ARGS := $(foreach yml,$(COMPOSE_FILES),-f $(yml)) - -ATTACH_COMPOSE_FILE_ARGS := $(foreach yml,$(filter-out tango.yml,$(COMPOSE_FILES)),-f $(yml)) - -# If the first make argument is "start" or "stop"... -ifeq (start,$(firstword $(MAKECMDGOALS))) - SERVICE_TARGET = true -else ifeq (stop,$(firstword $(MAKECMDGOALS))) - SERVICE_TARGET = true -else ifeq (attach,$(firstword $(MAKECMDGOALS))) - SERVICE_TARGET = true -ifndef NETWORK_MODE -$(error NETWORK_MODE must specify the network to attach to, e.g., make NETWORK_MODE=tangonet-powersupply ...) -endif -ifndef TANGO_HOST -$(error TANGO_HOST must specify the Tango database device, e.g., make TANGO_HOST=powersupply-databaseds:100000 ...) -endif -endif -ifdef SERVICE_TARGET - # .. then use the rest as arguments for the make target - SERVICE := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) - # ...and turn them into do-nothing targets - $(eval $(SERVICE):;@:) -endif - -# -# Never use the network=host mode when running CI jobs, and add extra -# distinguishing identifiers to the network name and container names to -# prevent collisions with jobs from the same project running at the same -# time. -# -ifneq ($(CI_JOB_ID),) -NETWORK_MODE := tangonet-$(CI_JOB_ID) -CONTAINER_NAME_PREFIX := $(CI_JOB_ID)- -else -CONTAINER_NAME_PREFIX := -$(info Network mode cannot be host for the archiver! It won't work unless you set the env var CI_JOB_ID=local) -endif - -ifeq ($(OS),Windows_NT) - $(error Sorry, Windows is not supported yet) -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Linux) - DISPLAY ?= :0.0 - NETWORK_MODE ?= host - XAUTHORITY_MOUNT := /tmp/.X11-unix:/tmp/.X11-unix - XAUTHORITY ?= /hosthome/.Xauthority - # /bin/sh (=dash) does not evaluate 'docker network' conditionals correctly - SHELL := /bin/bash - endif - ifeq ($(UNAME_S),Darwin) - IF_INTERFACE := $(shell scutil --nwi | grep 'Network interfaces:' | cut -d' ' -f3) - DISPLAY := $(shell scutil --nwi | grep 'address' | cut -d':' -f2 | tr -d ' ' | head -n1):0 - # network_mode = host doesn't work on MacOS, so fix to the internal network - NETWORK_MODE ?= tangonet - XAUTHORITY_MOUNT := $(HOME)/.Xauthority:/hosthome/.Xauthority:ro - XAUTHORITY := /hosthome/.Xauthority - endif -endif - -# -# When running in network=host mode, point devices at a port on the host -# machine rather than at the container. -# -ifeq ($(NETWORK_MODE),host) - TANGO_HOST := $(shell hostname):10000 - MYSQL_HOST := $(shell hostname):3306 -else - TANGO_HOST := $(CONTAINER_NAME_PREFIX)databaseds:10000 - MYSQL_HOST := $(CONTAINER_NAME_PREFIX)tangodb:3306 -endif - -DOCKER_COMPOSE_ARGS := DISPLAY=$(DISPLAY) XAUTHORITY=$(XAUTHORITY) TANGO_HOST=$(TANGO_HOST) \ - NETWORK_MODE=$(NETWORK_MODE) XAUTHORITY_MOUNT=$(XAUTHORITY_MOUNT) MYSQL_HOST=$(MYSQL_HOST) \ - CONTAINER_NAME_PREFIX=$(CONTAINER_NAME_PREFIX) COMPOSE_IGNORE_ORPHANS=true - - -.PHONY: up down minimal start stop status clean pull help -.DEFAULT_GOAL := help - -pull: ## pull the images from the Docker hub - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) pull - -up: minimal ## start the base TANGO system and prepare all services - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) up --no-start - -down: ## stop all services and tear down the system - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) down -ifneq ($(NETWORK_MODE),host) - docker network inspect $(NETWORK_MODE) &> /dev/null && ([ $$? -eq 0 ] && docker network rm $(NETWORK_MODE)) || true -endif - -minimal: ## start the base TANGO system -ifneq ($(NETWORK_MODE),host) - docker network inspect $(NETWORK_MODE) &> /dev/null || ([ $$? -ne 0 ] && docker network create $(NETWORK_MODE)) -endif - $(DOCKER_COMPOSE_ARGS) docker-compose -f tango.yml up -d - -start: up ## start a service (usage: make start <servicename>) - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) start $(SERVICE) - -stop: ## stop a service (usage: make stop <servicename>) - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) stop $(SERVICE) - -attach: ## attach a service to an existing Tango network - $(DOCKER_COMPOSE_ARGS) docker-compose $(ATTACH_COMPOSE_FILE_ARGS) up -d $(SERVICE) - -status: ## show the container status - $(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) ps - -clean: down ## clear all TANGO database entries - docker volume rm $(BASEDIR)_tangodb - -help: ## show this help. - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - diff --git a/docker-compose/archiver.yml b/docker-compose/archiver.yml deleted file mode 100644 index f1097b93e9ad938d5ca3957aa181737b882204eb..0000000000000000000000000000000000000000 --- a/docker-compose/archiver.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: '2' - -services: - maria-db: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/mariadb_hdbpp:latest - container_name: archiver-maria-db - network_mode: ${NETWORK_MODE} - depends_on: - - databaseds - environment: - - MYSQL_ROOT_PASSWORD=secret - - MYSQL_DATABASE=hdbpp - - MYSQL_HOST=archiver-maria-db:3306 - - MYSQL_USER=tango - - MYSQL_PASSWORD=tango - - TANGO_HOST=${TANGO_HOST} - restart: on-failure - - hdbpp-es: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-archiver:latest - network_mode: ${NETWORK_MODE} - container_name: hdbpp-es - depends_on: - - databaseds - - dsconfig - - maria-db - environment: - - TANGO_HOST=${TANGO_HOST} - - HdbManager=archiving/hdbpp/confmanager01 - command: > - /bin/bash -c " - wait-for-it.sh archiver-maria-db:3306 --timeout=30 --strict -- - wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - hdbppes-srv 01" - - hdbpp-cm: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-archiver:latest - network_mode: ${NETWORK_MODE} - container_name: hdbpp-cm - depends_on: - - databaseds - - dsconfig - - maria-db - environment: - - TANGO_HOST=${TANGO_HOST} - - HdbManager=archiving/hdbpp/confmanager01 - command: > - /bin/bash -c " - wait-for-it.sh archiver-maria-db:3306 --timeout=30 --strict -- - wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - hdbppcm-srv 01" - - dsconfig: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-dsconfig:latest - container_name: dsconfig - network_mode: ${NETWORK_MODE} - depends_on: - - databaseds - environment: - - TANGO_HOST=${TANGO_HOST} - command: > - sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- - json2tango -w -a -u /tango-archiver/data/archiver-devices.json && - sleep infinity" - volumes: - - ../docker/tango/tango-archiver:/tango-archiver - diff --git a/docker-compose/astor.yml b/docker-compose/astor.yml deleted file mode 100644 index 7911b66f9cda51aa6585fb37b18408eef6349754..0000000000000000000000000000000000000000 --- a/docker-compose/astor.yml +++ /dev/null @@ -1,50 +0,0 @@ -# -# Docker compose file that launches Astor, sending the display to a remote X11 -# display. -# -# Defines: -# - astor: service that runs Astor in a container -# - container1: example container running Starter device -# -# Requires: -# - tango.yml -# -version: '2' - -services: - astor: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-java:latest - container_name: ${CONTAINER_NAME_PREFIX}astor - network_mode: ${NETWORK_MODE} - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/astor - - starter-example: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-starter:latest - container_name: ${CONTAINER_NAME_PREFIX}starter-example - network_mode: ${NETWORK_MODE} - # set the hostname, otherwise duplicate device registrations result every - # time the hostname changes as the container is restarted. - hostname: starter-example - environment: - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/bin/supervisord - - --configuration - - /etc/supervisor/supervisord.conf diff --git a/docker-compose/hdbpp_viewer.yml b/docker-compose/hdbpp_viewer.yml deleted file mode 100644 index cf65548b25fca787e56a3ab03333daa09c12aa5b..0000000000000000000000000000000000000000 --- a/docker-compose/hdbpp_viewer.yml +++ /dev/null @@ -1,40 +0,0 @@ -# -# Docker compose file that launches HdbViewer, sending the display to a remote X11 -# display. -# -# -# Requires: -# - tango.yml -# -version: '2' - -services: - hdbpp-viewer: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/hdbpp_viewer:latest - container_name: ${CONTAINER_NAME_PREFIX}hdbpp-viewer - network_mode: ${NETWORK_MODE} - depends_on: - - databaseds - - dsconfig - - maria-db - - hdbpp-es - - hdbpp-cm - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - - HDB_TYPE=mysql - - HDB_MYSQL_HOST=archiver-maria-db - - HDB_MYSQL_PORT=3306 - - HDB_USER=tango - - HDB_PASSWORD=tango - - HDB_NAME=hdbpp - - CLASSPATH=JTango.jar:ATKCore.jar:ATKWidget.jar:jhdbviewer.jar:HDBPP.jar:jython.jar:jcalendar.jar - entrypoint: - - wait-for-it.sh - - ${TANGO_HOST} - - --strict - - -- - - ./hdbpp_viewer/hdbpp_viewer_script diff --git a/docker-compose/itango.yml b/docker-compose/itango.yml deleted file mode 100644 index 89df69cce66da87dc206580561629b59e0e28581..0000000000000000000000000000000000000000 --- a/docker-compose/itango.yml +++ /dev/null @@ -1,30 +0,0 @@ -# -# Docker compose file that launches an interactive iTango session. -# -# Connect to the interactive session with 'docker attach itango'. -# Disconnect with the Docker deattach sequence: <CTRL>+<P> <CTRL>+<Q> -# -# Defines: -# - itango: iTango interactive session -# -# Requires: -# - tango.yml -# -version: '2' - -services: - itango: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-itango:latest - container_name: ${CONTAINER_NAME_PREFIX}itango - network_mode: ${NETWORK_MODE} - environment: - - TANGO_HOST=${TANGO_HOST} - stdin_open: true - tty: true - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /venv/bin/itango3 diff --git a/docker-compose/jive.yml b/docker-compose/jive.yml deleted file mode 100644 index 4a57882095cabafa462c2cfcdebe6070fca83d03..0000000000000000000000000000000000000000 --- a/docker-compose/jive.yml +++ /dev/null @@ -1,30 +0,0 @@ -# -# Docker compose file that launches Jive, sending output to a remote X11 -# display. -# -# Defines: -# - jive: container running Jive -# -# Requires: -# - tango.yml -# -version: '2' - -services: - jive: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-java:latest - container_name: ${CONTAINER_NAME_PREFIX}jive - network_mode: ${NETWORK_MODE} - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/jive diff --git a/docker-compose/logviewer.yml b/docker-compose/logviewer.yml deleted file mode 100644 index ad1d975ec4f611a393bbb12250e582b4ae33671a..0000000000000000000000000000000000000000 --- a/docker-compose/logviewer.yml +++ /dev/null @@ -1,30 +0,0 @@ -# -# Docker compose file that launches LogViewer, sending output to a remote X11 -# display. -# -# Defines: -# - logviewer: container running LogViewer -# -# Requires: -# - tango.yml -# -version: '2' - -services: - logviewer: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-java:latest - container_name: ${CONTAINER_NAME_PREFIX}logviewer - network_mode: ${NETWORK_MODE} - volumes: - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/logviewer diff --git a/docker-compose/pogo.yml b/docker-compose/pogo.yml deleted file mode 100644 index 157fab05f1e1665d6624f8a6e36f6827f05b75a7..0000000000000000000000000000000000000000 --- a/docker-compose/pogo.yml +++ /dev/null @@ -1,32 +0,0 @@ -# -# Docker compose file that launches Pogo, sending the display to a remote X11 -# display. Pogo output can be persisted by writing to either: -# 1. the /home/tango folder, which is a Docker volume persisted between -# container runs; -# 2. the /hosthome folder, which is a r/w mount of your home folder. -# -# Defines: -# - pogo (service): service running Pogo -# - pogo (volume): persistent volume for writing Pogo outut -# -# Requires: -# - N/A -# -version: '2' - -# Create a volume so that Pogo preferences and Pogo output can be persisted -volumes: - pogo: {} - -services: - pogo: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-pogo:latest - container_name: ${CONTAINER_NAME_PREFIX}pogo - network_mode: ${NETWORK_MODE} - volumes: - - pogo:/home/tango - - ${HOME}:/hosthome:rw - - ${XAUTHORITY_MOUNT} - environment: - - XAUTHORITY=${XAUTHORITY} - - DISPLAY=${DISPLAY} diff --git a/docker-compose/rest.yml b/docker-compose/rest.yml deleted file mode 100644 index dfbd154b270eb9b6f74ce6b769660e43ebd58b14..0000000000000000000000000000000000000000 --- a/docker-compose/rest.yml +++ /dev/null @@ -1,34 +0,0 @@ -# -# Docker compose file that launches Astor, sending the display to a remote X11 -# display. -# -# Defines: -# - astor: service that runs Astor in a container -# - container1: example container running Starter device -# -# Requires: -# - tango.yml -# -version: '2' - -services: - rest: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-rest:latest - container_name: ${CONTAINER_NAME_PREFIX}tango-rest - network_mode: ${NETWORK_MODE} - # set the hostname, otherwise duplicate device registrations result every - # time the hostname changes as the container is restarted. - hostname: tango-rest - environment: - - TANGO_HOST=${TANGO_HOST} - ports: - - 8080:8080 - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/bin/supervisord - - --configuration - - /etc/supervisor/supervisord.conf diff --git a/docker-compose/tango.yml b/docker-compose/tango.yml deleted file mode 100644 index f87788b9c2991d738a9a592bed955eae988fbee9..0000000000000000000000000000000000000000 --- a/docker-compose/tango.yml +++ /dev/null @@ -1,52 +0,0 @@ -# -# Docker compose file for TANGO database and database device server -# -# Defines: -# - tangodb: MariaDB database with TANGO schema -# - databaseds: TANGO database device server -# -# Requires: -# - None -# -version: '2' - -volumes: - tangodb: {} - -services: - tangodb: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-db:latest - container_name: ${CONTAINER_NAME_PREFIX}tangodb - network_mode: ${NETWORK_MODE} - environment: - - MYSQL_ROOT_PASSWORD=secret - - MYSQL_DATABASE=tango - - MYSQL_USER=tango - - MYSQL_PASSWORD=tango - volumes: - - tangodb:/var/lib/mysql - restart: on-failure - - databaseds: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-cpp:latest - container_name: ${CONTAINER_NAME_PREFIX}databaseds - network_mode: ${NETWORK_MODE} - depends_on: - - tangodb - environment: - - MYSQL_HOST=${MYSQL_HOST} - - MYSQL_DATABASE=tango - - MYSQL_USER=tango - - MYSQL_PASSWORD=tango - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${MYSQL_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/DataBaseds - - "2" - - -ORBendPoint - - giop:tcp::10000 - restart: on-failure diff --git a/docker-compose/tangotest.yml b/docker-compose/tangotest.yml deleted file mode 100644 index c2be7247749990377932159692631fb79fbd4335..0000000000000000000000000000000000000000 --- a/docker-compose/tangotest.yml +++ /dev/null @@ -1,28 +0,0 @@ -# -# Docker compose file for TANGO test device server. -# -# Defines: -# - tangotest: TANGO test device server -# -# Requires: -# - tango.yml -# -version: '2' - -services: - tangotest: - image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/tango-java:latest - container_name: ${CONTAINER_NAME_PREFIX}tangotest - network_mode: ${NETWORK_MODE} - environment: - - TANGO_HOST=${TANGO_HOST} - entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- - - /usr/local/bin/TangoTest - - test - restart: on-failure - diff --git a/docker/deploy/.release b/docker/deploy/.release index 88399d0d0939bc3caa1f9c01f46df613bd9a6c70..620cb4e115b13bba95085abce55d9177241af4ab 100644 --- a/docker/deploy/.release +++ b/docker/deploy/.release @@ -1,2 +1,2 @@ -release=0.4.2 -tag=deploy-0.4.2 +release=0.4.3 +tag=deploy-0.4.3 diff --git a/docker/deploy/Dockerfile b/docker/deploy/Dockerfile index cf098ca4fdaa9799ed73a4f24b5aa352e4e5b321..3f34b6ac9e114215e67be08212ac8a10204567d9 100644 --- a/docker/deploy/Dockerfile +++ b/docker/deploy/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -ENV KUBE_LATEST_VERSION="v1.16.2" +ENV KUBE_LATEST_VERSION="v1.18.2" ENV HELM_VERSION="v3.3.1" ENV DEBIAN_FRONTEND="noninteractive" ENV RUNLEVEL="1" diff --git a/docker/tango/ska-python-buildenv/test/Makefile b/docker/tango/ska-python-buildenv/test/Makefile deleted file mode 100644 index 3e8a2bbc0d987fb95e21676d1fcfe37eee01184e..0000000000000000000000000000000000000000 --- a/docker/tango/ska-python-buildenv/test/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -all: test - -test: - # It takes several seconds for the Tango database to be populated from - # scratch, so pause until DB is created and the device we test against is - # responsive. If the Tango DB volume already exists, there'll be no delay - # at all and the test will run immediately. - retry -- tango_admin --check-device sys/tg_test/1 - pytest SimpleTest.py - -.PHONY: all test diff --git a/docker/tango/ska-python-buildenv/test/SimpleTest.py b/docker/tango/ska-python-buildenv/test/SimpleTest.py deleted file mode 100644 index 821f23b6443d18b0d9ad4ff0ca4b746b86858d37..0000000000000000000000000000000000000000 --- a/docker/tango/ska-python-buildenv/test/SimpleTest.py +++ /dev/null @@ -1,6 +0,0 @@ -import tango - - -def test_test_device_is_running(): - tango_test = tango.DeviceProxy("sys/tg_test/1") - assert tango_test.state() == tango.DevState.RUNNING diff --git a/docker/tango/tango-archiver/test/Makefile b/docker/tango/tango-archiver/test/Makefile deleted file mode 100644 index 9c29d6a1762c0ae9aa8d9e1ac32caf4c46bba1b1..0000000000000000000000000000000000000000 --- a/docker/tango/tango-archiver/test/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -SHELL = /bin/bash -.SHELLFLAGS = -o pipefail -c - -all: test - -test: - retry --max=10 -- tango_admin --ping-device archiving/hdbpp/eventsubscriber01 && \ - pytest SimpleTest.py - -.PHONY: all test diff --git a/docker/tango/tango-cpp/test/wait-for-it.sh b/docker/tango/tango-cpp/test/wait-for-it.sh deleted file mode 100755 index eca6c3b9c8c61aa6ce889c185c700ad094988cc2..0000000000000000000000000000000000000000 --- a/docker/tango/tango-cpp/test/wait-for-it.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI="$@" - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec $CLI -else - exit $RESULT -fi diff --git a/docker/tango/tango-db/test/test.sh b/docker/tango/tango-db/test/test.sh deleted file mode 100755 index 6e8dfc397ada99a33f7baaf0476dc3a427cc7bb0..0000000000000000000000000000000000000000 --- a/docker/tango/tango-db/test/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -result=$(mysql -h $1 -u tango -ptango <<< 'show databases') - -if [[ $result =~ "tango" ]] -then - echo "PASSED" -else - echo "ERROR" - exit 1 -fi diff --git a/docker/tango/tango-db/test/wait-for-it.sh b/docker/tango/tango-db/test/wait-for-it.sh deleted file mode 100755 index eca6c3b9c8c61aa6ce889c185c700ad094988cc2..0000000000000000000000000000000000000000 --- a/docker/tango/tango-db/test/wait-for-it.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI="$@" - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec $CLI -else - exit $RESULT -fi diff --git a/docker/tango/tango-itango/test/Makefile b/docker/tango/tango-itango/test/Makefile deleted file mode 100644 index 1acd6def88d662e3ca09a81f601491d4d52e2019..0000000000000000000000000000000000000000 --- a/docker/tango/tango-itango/test/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: test - -test: - [ -f /.dockerenv ] && sudo apt-get update && sudo apt-get -y install --no-install-recommends expect || true - # It takes several seconds for the tango database to be populated from - # scratch, so pause until DB is created and the device we test against is - # responsive. If the Tango DB volume already exists, there'll be no pause - # delay at all and the test will run immediately. - retry -- tango_admin --check-device sys/tg_test/1 - ./script.exp - -.PHONY: all test diff --git a/post-deployment/.gitignore b/post-deployment/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..12fb62e8f55ab1913359afc7a046f4f2ffd5eef1 --- /dev/null +++ b/post-deployment/.gitignore @@ -0,0 +1,2 @@ +Pipfile +Pipfile.lock \ No newline at end of file diff --git a/post-deployment/Makefile b/post-deployment/Makefile index 55d735c3fbcec6eb4d81e9f356ffd8a197aa1261..4efb6c8c3b233847d32b0adcb6afaddbcde1f4fb 100644 --- a/post-deployment/Makefile +++ b/post-deployment/Makefile @@ -18,6 +18,7 @@ test: install find . -name "*.pyc" -type f -delete && \ PYTHONPATH=/app:/app/testing:/app/testing/post-deployment pytest $(if $(findstring all,$(MARK)),, -m $(MARK)) --disable-pytest-warnings | tee pytest.stdout; \ status=$$?; \ + echo "Status set at \"$$status\" in post-deployment/Makefile test target"; \ $(foreach artfct,$(TEST_ARTIFACTS),mv -f $(artfct) build/;) \ exit $$status diff --git a/post-deployment/features/archiver.feature b/post-deployment/features/archiver.feature new file mode 100644 index 0000000000000000000000000000000000000000..6bd0825f1dea77a72926406da7e651afa49a7791 --- /dev/null +++ b/post-deployment/features/archiver.feature @@ -0,0 +1,16 @@ +#check device is ON +Scenario: Test Configuration Manager device is ON + Given a device called archiving/hdbpp/confmanager01 + When I call the command state() + Then the attribute DevState is ON + +Scenario: Test Event Subscriber device is ON + Given a device called archiving/hdbpp/eventsubscriber01 + When I call the command state() + Then the attribute DevState is ON + +#check archiving is started +Scenario: Check archiving + Given a Configuration Manager called archiving/hdbpp/confmanager01 and an Event Subscriber called archiving/hdbpp/eventsubscriber01 + When I request to archive the attribute sys/tg_test/1/double_scalar + Then after 1000 milliseconds the Archiving is Started diff --git a/post-deployment/features/tango-commands.feature b/post-deployment/features/tango-commands.feature new file mode 100644 index 0000000000000000000000000000000000000000..9fcb5cb93f25eae7d571fe1334787c54be1a7cf6 --- /dev/null +++ b/post-deployment/features/tango-commands.feature @@ -0,0 +1,29 @@ +# check devices +Feature: Test commands and attributes + +Scenario: Check attribute for test device + Given a device called sys/tg_test/1 + Then the attribute State is RUNNING + +Scenario: Call Command and check result + Given a device called sys/tg_test/1 + When I call the command State() + Then the result is RUNNING + +Scenario: Call Command and test attribute for database + Given a device called sys/database/2 + When I call the command State() + Then the result is ON + +Scenario: Test DevString command + Given a device called sys/tg_test/1 + When I call the command DevString(Hello World!) + Then the result is Hello World! + +Scenario: Test short_spectrum_ro quality + Given a device called sys/tg_test/1 + Then the attribute short_spectrum_ro is ATTR_VALID + +Scenario: Test short_spectrum quality + Given a device called sys/tg_test/1 + Then the attribute short_spectrum is ATTR_VALID \ No newline at end of file diff --git a/post-deployment/features/tango-db.feature b/post-deployment/features/tango-db.feature new file mode 100644 index 0000000000000000000000000000000000000000..a404f460f7c189d044ee1c9cf96943e94307bb4c --- /dev/null +++ b/post-deployment/features/tango-db.feature @@ -0,0 +1,11 @@ + +Feature: tango-db + Test tango db connection + +Scenario: Test mysql connection + Given Tango env tango_values.yaml + When I extract the DB config in the databaseds-tango-base-test + Then I check the tango database connection + +# ping database + diff --git a/post-deployment/features/tango_tools.feature b/post-deployment/features/tango_tools.feature new file mode 100644 index 0000000000000000000000000000000000000000..e69e513b0476e700db752368abdce8c6d39473f5 --- /dev/null +++ b/post-deployment/features/tango_tools.feature @@ -0,0 +1,12 @@ +Feature: Test tango tools + +Scenario: Connect to the tango database using tango_admin + Given the TANGO_HOST is defined in the environment + When I call the tango_admin command with parameter ping-database + Then the return code is 0 + +@xfail +Scenario: Test starting itango session + Given the TANGO_HOST is defined in the environment + When I call the itango3 command with parameter simple-prompt + Then the return code is 0 diff --git a/docker/tango/tango-rest/test/Makefile b/post-deployment/resources/_old/Makefile similarity index 100% rename from docker/tango/tango-rest/test/Makefile rename to post-deployment/resources/_old/Makefile diff --git a/docker/tango/tango-itango/test/script.exp b/post-deployment/resources/_old/script.exp similarity index 100% rename from docker/tango/tango-itango/test/script.exp rename to post-deployment/resources/_old/script.exp diff --git a/docker/tango/tango-cpp/test/test.sh b/post-deployment/resources/_old/test-tango-admin.sh similarity index 100% rename from docker/tango/tango-cpp/test/test.sh rename to post-deployment/resources/_old/test-tango-admin.sh diff --git a/docker/tango/tango-archiver/test/SimpleTest.py b/post-deployment/resources/_old/test_archiver.py similarity index 100% rename from docker/tango/tango-archiver/test/SimpleTest.py rename to post-deployment/resources/_old/test_archiver.py diff --git a/post-deployment/tests/test_device_running.py b/post-deployment/resources/_old/test_device_running.py similarity index 100% rename from post-deployment/tests/test_device_running.py rename to post-deployment/resources/_old/test_device_running.py diff --git a/post-deployment/resources/test_support/fixtures.py b/post-deployment/resources/test_support/fixtures.py new file mode 100644 index 0000000000000000000000000000000000000000..92235e2f9c8332d386e4e411768b54819b73f98f --- /dev/null +++ b/post-deployment/resources/test_support/fixtures.py @@ -0,0 +1,25 @@ +import logging +import functools, os +from sys import exec_prefix +from collections import namedtuple + +import pytest +from tango import DeviceProxy + +LOGGER = logging.getLogger(__name__) + +## pytest fixtures +ENV_VARS = [ + 'HELM_RELEASE', + 'KUBE_NAMESPACE', + 'TANGO_HOST'] +RunContext = namedtuple('RunContext', ENV_VARS) +@pytest.fixture(scope="session") +def run_context(): + # list of required environment vars + values = list() + + for var in ENV_VARS: + assert os.environ.get(var) # all ENV_VARS must have values set + values.append(os.environ.get(var)) + return RunContext(*values) \ No newline at end of file diff --git a/post-deployment/test_requirements.txt b/post-deployment/test_requirements.txt index 476f694f0bfdcb58536e4cc342f6c5e7148d28c4..79e51594841e3b7214ed4c685f2f9dbbd37fd812 100644 --- a/post-deployment/test_requirements.txt +++ b/post-deployment/test_requirements.txt @@ -19,4 +19,6 @@ ska_logging aiohttp_cors flake8 tango-simlib==0.7.0 -lmcbaseclasses \ No newline at end of file +lmcbaseclasses +mysql-connector-python +itango \ No newline at end of file diff --git a/post-deployment/tests/conftest.py b/post-deployment/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..7d078b7804c19660e6680467b65749544e29a86f --- /dev/null +++ b/post-deployment/tests/conftest.py @@ -0,0 +1,26 @@ +import os +import pytest +import logging + +from tango import DeviceProxy +from collections import namedtuple + +## shared fixtures +from resources.test_support.fixtures import run_context + +""" +Taken from https://gitlab.com/ska-telescope/skampi/-/blob/21e00f36a5fa797ad816ec8c40954f6a3a70b040/post-deployment/tests/conftest.py + +RunContext is a metadata object to access values from the environment, +i.e. data that is injected in by the Makefile. Useful if tests need to +be aware of the k8s context they are running in, such as the HELM_RELEASE. + +This will allow tests to resolve hostnames and other dynamic properties. + +Example: + +def test_something(run_context): + HOSTNAME = 'some-pod-{}'.format(run_context.HELM_RELEASE) + +""" + diff --git a/post-deployment/tests/test_archiver.py b/post-deployment/tests/test_archiver.py index 2b58a985496b03af0867bc716101841febb027a0..7e4b2f08993f924d08af6f3bdeb6810d438b018b 100644 --- a/post-deployment/tests/test_archiver.py +++ b/post-deployment/tests/test_archiver.py @@ -1,71 +1,73 @@ +# coding=utf-8 +"""features/archiver.feature feature tests.""" + import tango -from tango import DevFailed, DeviceProxy, GreenMode, AttributeProxy -import time +from tango import DevFailed, DeviceProxy from time import sleep import pytest import logging +from pytest_bdd import given, scenario, then, when, parsers -def test_cm_device_is_ON(): - tango_test = tango.DeviceProxy("archiving/hdbpp/confmanager01") - time.sleep(2) - assert tango_test.state() == tango.DevState.ON +pytest.device_proxies = [] -def test_es_device_is_ON(): - tango_test = tango.DeviceProxy("archiving/hdbpp/eventsubscriber01") - time.sleep(2) - assert tango_test.state() == tango.DevState.ON -def test_archiving(): - evt_subscriber_device_fqdn = "archiving/hdbpp/eventsubscriber01" - config_manager_device_fqdn = "archiving/hdbpp/confmanager01" - conf_manager_proxy = DeviceProxy(config_manager_device_fqdn) - evt_subscriber_device_proxy = DeviceProxy(evt_subscriber_device_fqdn) +@scenario('archiver.feature', 'Check archiving') +def test_archiver(): + """Test archiver.""" - conf_manager_proxy.set_timeout_millis(5000) - evt_subscriber_device_proxy.set_timeout_millis(5000) - attribute = "sys/tg_test/1/double_scalar" +@given(parsers.parse('a Configuration Manager called {cm_device_name} and an Event Subscriber called {' + 'es_device_name}')) +def device_proxy(run_context, cm_device_name, es_device_name): + """a Configuration Manager called archiving/hdbpp/confmanager01 and + an Event Subscriber called archiving/hdbpp/eventsubscriber01.""" + pytest.conf_manager_device = tango.DeviceProxy(cm_device_name) + pytest.event_subscriber_device = tango.DeviceProxy(es_device_name) - # wait for the attribute to be online. - max_retries = 10 - sleep_time = 30 - for x in range(0, max_retries): - try: - att = AttributeProxy(attribute) - att.read() - break - except DevFailed as df: - if(x == (max_retries -1)): - raise df - logging.info("DevFailed exception: " + str(df.args[0].reason) + ". Sleeping for " + str(sleep_time) + "ss") - sleep(sleep_time) - conf_manager_proxy.write_attribute("SetAttributeName", attribute) - conf_manager_proxy.write_attribute("SetArchiver", evt_subscriber_device_fqdn) - conf_manager_proxy.write_attribute("SetStrategy", "ALWAYS") - conf_manager_proxy.write_attribute("SetPollingPeriod", 1000) - conf_manager_proxy.write_attribute("SetPeriodEvent", 3000) +@pytest.fixture +@when(parsers.parse("I request to archive the attribute {attribute_name}")) +def archive_attribute(device_proxy, attribute_name): + """Attribute is set to sys/tg_test/1/double_scalar.""" + conf_manager_proxy = pytest.conf_manager_device - try: - conf_manager_proxy.command_inout("AttributeAdd") - except DevFailed as df: - if not str(df.args[0].reason) == 'Already archived': - logging.info("DevFailed exception: " + str(df.args[0].reason)) + evt_subscriber_device_proxy = pytest.event_subscriber_device - evt_subscriber_device_proxy.Start() + conf_manager_proxy.set_timeout_millis(5000) + evt_subscriber_device_proxy.set_timeout_millis(5000) + conf_manager_proxy.write_attribute("SetAttributeName", attribute_name) + conf_manager_proxy.write_attribute("SetArchiver", evt_subscriber_device_proxy.name()) + conf_manager_proxy.write_attribute("SetStrategy", "ALWAYS") + conf_manager_proxy.write_attribute("SetPollingPeriod", 1000) + conf_manager_proxy.write_attribute("SetPeriodEvent", 3000) - max_retries = 10 - sleep_time = 1 - for x in range(0, max_retries): try: - # Check status of Attribute Archiving in Configuration Manager - result_config_manager = conf_manager_proxy.command_inout("AttributeStatus", attribute) - # Check status of Attribute Archiving in Event Subscriber - result_evt_subscriber = evt_subscriber_device_proxy.command_inout("AttributeStatus", attribute) - assert "Archiving : Started" in result_config_manager - assert "Archiving : Started" in result_evt_subscriber + conf_manager_proxy.command_inout("AttributeAdd") except DevFailed as df: - if(x == (max_retries -1)): - raise df - logging.info("DevFailed exception: " + str(df.args[0].reason) + ". Sleeping for " + str(sleep_time) + "ss") - sleep(sleep_time) + if not str(df.args[0].reason) == 'Already archived': + logging.info("DevFailed exception: " + str(df.args[0].reason)) + + evt_subscriber_device_proxy.Start() + return attribute_name + + +@then(parsers.parse("after {time_interval} milliseconds the Archiving is Started")) +def check_archiving(device_proxy, archive_attribute): + """The time interval is 1 second.""" + attribute = archive_attribute + max_retries = 10 + sleep_time = 1 + for x in range(0, max_retries): + try: + # Check status of Attribute Archiving in Configuration Manager + result_config_manager = pytest.conf_manager_device.command_inout("AttributeStatus", attribute) + # Check status of Attribute Archiving in Event Subscriber + result_evt_subscriber = pytest.event_subscriber_device.command_inout("AttributeStatus", attribute) + assert "Archiving : Started" in result_config_manager + assert "Archiving : Started" in result_evt_subscriber + except DevFailed as df: + if x == (max_retries - 1): + raise df + logging.info( + "DevFailed exception: " + str(df.args[0].reason) + ". Sleeping for " + str(sleep_time) + "ss") + sleep(sleep_time) diff --git a/post-deployment/tests/test_tango-commands.py b/post-deployment/tests/test_tango-commands.py new file mode 100644 index 0000000000000000000000000000000000000000..80b0657e7d3a005cd1cbe4e2e9388464ea47c4dc --- /dev/null +++ b/post-deployment/tests/test_tango-commands.py @@ -0,0 +1,88 @@ +# coding=utf-8 +"""features/tango-cpp.feature feature tests.""" +import tango +import logging +import pytest +from tango import Database, DeviceProxy, CmdArgType as ArgType + +from pytest_bdd import given, scenario, then, when, parsers, scenarios + +scenarios('../features/tango-commands.feature') + +@given(parsers.parse('a device called {device_name}')) +def device_proxy(run_context, device_name): + """a device called sys/tg_test/1.""" + return tango.DeviceProxy(device_name) + + +@pytest.fixture +@when(parsers.cfparse("I call the command {command_name}({parameter:String?})", extra_types=dict(String=str))) +def call_command(device_proxy,command_name, parameter): + """I call the command State().""" + # logging.info("Called command: {} with parameter {} for device {}".format(command_name, parameter, device_proxy.info())) + if parameter is None: + return device_proxy.command_inout(command_name) + else: + command_info = device_proxy.command_query(command_name) + # {0: tango._tango.CmdArgType.DevVoid, + # 1: tango._tango.CmdArgType.DevBoolean,* + # 2: tango._tango.CmdArgType.DevShort,* + # 3: tango._tango.CmdArgType.DevLong,* + # 4: tango._tango.CmdArgType.DevFloat,* + # 5: tango._tango.CmdArgType.DevDouble,* + # 6: tango._tango.CmdArgType.DevUShort,* + # 7: tango._tango.CmdArgType.DevULong,* + # 8: tango._tango.CmdArgType.DevString,* + # 9: tango._tango.CmdArgType.DevVarCharArray, + # 10: tango._tango.CmdArgType.DevVarShortArray, + # 11: tango._tango.CmdArgType.DevVarLongArray, + # 12: tango._tango.CmdArgType.DevVarFloatArray, + # 13: tango._tango.CmdArgType.DevVarDoubleArray, + # 14: tango._tango.CmdArgType.DevVarUShortArray, + # 15: tango._tango.CmdArgType.DevVarULongArray, + # 16: tango._tango.CmdArgType.DevVarStringArray, + # 17: tango._tango.CmdArgType.DevVarLongStringArray, + # 18: tango._tango.CmdArgType.DevVarDoubleStringArray, + # 19: tango._tango.CmdArgType.DevState, + # 20: tango._tango.CmdArgType.ConstDevString, + # 21: tango._tango.CmdArgType.DevVarBooleanArray, + # 22: tango._tango.CmdArgType.DevUChar, + # 23: tango._tango.CmdArgType.DevLong64,* + # 24: tango._tango.CmdArgType.DevULong64,* + # 25: tango._tango.CmdArgType.DevVarLong64Array, + # 26: tango._tango.CmdArgType.DevVarULong64Array, + # 27: tango._tango.CmdArgType.DevInt,* + # 28: tango._tango.CmdArgType.DevEncoded, *****???????? + # 29: tango._tango.CmdArgType.DevEnum, *****???????? + # 30: tango._tango.CmdArgType.DevPipeBlob, *****???????? + # 31: tango._tango.CmdArgType.DevVarStateArray} + if(command_info.in_type == ArgType.DevShort or + command_info.in_type == ArgType.DevLong or + command_info.in_type == ArgType.DevUShort or + command_info.in_type == ArgType.DevULong or + command_info.in_type == ArgType.DevLong64 or + command_info.in_type == ArgType.DevULong64 or + command_info.in_type == ArgType.DevInt): + return device_proxy.command_inout(command_name, int(parameter)) + if(command_info.in_type == ArgType.DevFloat or + command_info.in_type == ArgType.DevDouble): + return device_proxy.command_inout(command_name, float(parameter)) + if(command_info.in_type == ArgType.DevBoolean): + return device_proxy.command_inout(command_name, bool(parameter)) + + return device_proxy.command_inout(command_name, parameter) + + +@then(parsers.parse('the attribute {attribute_name} is {expected_value}')) +def check_attribute(device_proxy, attribute_name, expected_value): + """the attribute State is RUNNING.""" + attr = device_proxy.read_attribute(attribute_name) + # logging.info("Attribute: {}".format(attr)) + if attr.data_format == tango._tango.AttrDataFormat.SCALAR: + assert str(attr.value) == expected_value + elif attr.data_format == tango._tango.AttrDataFormat.SPECTRUM: + assert str(attr.quality) == expected_value + +@then(parsers.parse("the result is {expected_result}")) +def check_command(device_proxy, call_command, expected_result): + assert str(call_command) == expected_result diff --git a/post-deployment/tests/test_tango-db.py b/post-deployment/tests/test_tango-db.py new file mode 100644 index 0000000000000000000000000000000000000000..1214c8b4a8ba0c9027cf55f1d24735b13f2f2408 --- /dev/null +++ b/post-deployment/tests/test_tango-db.py @@ -0,0 +1,62 @@ +import logging +import pytest +from pytest_bdd import scenario, given, when, then, scenarios, parsers +import yaml +import mysql.connector +from mysql.connector import errorcode + +pytest.namespace = "" + +@given(parsers.parse("Tango env {values_file}")) +def getValuesFile(values_file): + + try: + with open(values_file) as file: + pytest.values_list = yaml.load(file, Loader=yaml.FullLoader) + except Exception as e: + pytest.raises(e) + + + +@when(parsers.parse("I extract the DB config in the {device_name}")) +def getDBConfig(device_name): + + try: + deviceList : list = pytest.values_list['deviceServers'] + + for device in deviceList: + if device['name'] == device_name: + varList: list = device['environment_variables'] + + for var in varList: + if var['name'] == 'MYSQL_HOST': + host : str = var['value'] + pytest.dbHost = host.split(":")[0] + if var['name'] == 'MYSQL_DATABASE': + pytest.dbName = var['value'] + if var['name'] == 'MYSQL_USER': + pytest.dbUser = var['value'] + if var['name'] == 'MYSQL_PASSWORD': + pytest.dbPassword = var['value'] + + except Exception as e: + pytest.raises(e) + + +@then(parsers.parse("I check the tango database connection")) +def checkDB(): + try: + cnx = mysql.connector.connect( + user=pytest.dbUser, + password=pytest.dbPassword, + host=pytest.dbHost, + database=pytest.dbName + ) + + except mysql.connector.Error as err: + logging.error(err) + pytest.raises(Exception("Database connection Error")) + else: + cnx.close() + +scenarios('../features/tango-db.feature') diff --git a/post-deployment/tests/test_tango_tools.py b/post-deployment/tests/test_tango_tools.py new file mode 100644 index 0000000000000000000000000000000000000000..109c8ca5ba453da4898d14e0c27854901e8e06e9 --- /dev/null +++ b/post-deployment/tests/test_tango_tools.py @@ -0,0 +1,38 @@ +# coding=utf-8 +"""tango_tools.feature feature tests.""" +import tango +import logging +import pytest +import subprocess + +from pytest_bdd import given, scenario, then, when, parsers, scenarios + + +@given('the TANGO_HOST is defined in the environment') +def the_tango_host_is_defined_in_the_environment(run_context): + """the TANGO_HOST is defined in the environment.""" + # logging.info("TANGO_HOST: {}".format(run_context.TANGO_HOST)) + assert run_context.TANGO_HOST == 'databaseds-tango-base-test:10000', "RunContext has unexpected TANGO_HOST variable: {}".format(run_context.TANGO_HOST) + + +# @pytest.fixture +@when(parsers.parse('I call the {command} command with parameter {parameter}')) +def call_command(command, parameter): + """I call a command with parameter.""" + + if parameter == "ping-database": + # logging.info("Running command {} with param {}".format(command, parameter)) + pytest.result = subprocess.run([command, "--"+parameter, "20"]) + elif command == "itango3": + # logging.info("Running command {} with param {}".format(command, parameter)) + pytest.result = subprocess.run([command, "--"+parameter]) + + +@then('the return code is 0') +def check_return_code(): + """the result is 0.""" + # return_code = call_command.returncode + return_code = pytest.result.returncode + assert return_code == 0, "Function returned {}".format(pytest.result) + +scenarios('../features/tango_tools.feature')