From ec252e70691ec8051e044c555c1d432fab66cba8 Mon Sep 17 00:00:00 2001 From: One-Fine-Day Date: Fri, 2 Mar 2018 16:51:09 -0600 Subject: [PATCH] Updated Makefile ARMADA-29: CI/CD Armada Testing Framework Entrypoints defined It does not appear the the docker run command to call tox tests/unit is necessary. The Makefile already includes several testing checks. Added a few additional targets as specified in the upc-integration code-convenstions to satisfy the clcp Makefile standards. Change-Id: Ia920a856ed6d607fcf38d5f85dbb9a0c8aae4fa6 --- Makefile | 42 ++++++++++++-- armada/conf/default.py | 5 -- docs/source/development/getting-started.rst | 44 +++++++++++++++ entrypoint.sh | 2 +- etc/armada/api-paste.ini | 1 + tools/armada_image_run.sh | 61 +++++++++++++++++++++ tox.ini | 1 + 7 files changed, 145 insertions(+), 11 deletions(-) create mode 100755 tools/armada_image_run.sh diff --git a/Makefile b/Makefile index dc63da39..9f4fb164 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,27 @@ +# Copyright 2018 AT&T Intellectual Property. All other rights reserved. +# +# 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. + # APP INFO DOCKER_REGISTRY ?= quay.io IMAGE_PREFIX ?= attcomdev IMAGE_NAME ?= armada +IMAGE_TAG ?= latest HELM ?= helm LABEL ?= commit-id PYTHON = python3 CHART = armada +IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} # VERSION INFO GIT_COMMIT = $(shell git rev-parse HEAD) @@ -17,8 +33,7 @@ ifdef VERSION DOCKER_VERSION = $(VERSION) endif -IMAGE_TAG ?= git-${GIT_SHA} -IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} + SHELL = /bin/bash info: @@ -58,9 +73,8 @@ check-tox: exit 2; \ fi -.PHONY: docker-build -images: check-docker - docker build --rm -t ${IMAGE} --label $(LABEL) . +.PHONY: images +images: check-docker build_armada .PHONY: dry-run dry-run: clean @@ -68,6 +82,24 @@ dry-run: clean $(HELM) dep up charts/$(CHART) $(HELM) template charts/$(CHART) +.PHONY: docs +docs: build_docs + +.PHONY: run_images +run_images: run_armada + +.PHONY: run_armada +run_armada: build_armada + ./tools/armada_image_run.sh $(IMAGE) + +.PHONY: build_docs +build_docs: + tox -e docs + +.PHONY: build_armada +build_armada: + docker build -t $(IMAGE) --label $(LABEL) . + # make tools .PHONY: protoc protoc: diff --git a/armada/conf/default.py b/armada/conf/default.py index f8648a46..acac4fbc 100644 --- a/armada/conf/default.py +++ b/armada/conf/default.py @@ -89,11 +89,6 @@ path to the private key that includes the name of the key itself.""")), 'tiller_release_roles', default=['admin'], help=utils.fmt('IDs of approved API access roles.')), - - cfg.ListOpt( - 'tiller_status_roles', - default=['admin'], - help=utils.fmt('IDs of approved API access roles.')) ] diff --git a/docs/source/development/getting-started.rst b/docs/source/development/getting-started.rst index 9eecbb2b..41194d5f 100644 --- a/docs/source/development/getting-started.rst +++ b/docs/source/development/getting-started.rst @@ -211,6 +211,10 @@ To run the Python linter, execute:: $ tox -e pep8 + or + + $ make test-pep8 + To lint Helm charts, execute:: $ make lint @@ -219,18 +223,58 @@ To run unit tests, execute:: $ tox -e py35 + or + + $ make test-unit + To run the test coverage job:: $ tox -e coverage + or + + $ make test-coverage + To run security checks via `Bandit`_ execute:: $ tox -e bandit + or + + $ make test-bandit + +To build the docker images:: + + $ make images + To build all Armada charts, execute:: $ make charts +To build a helm template for the charts:: + + $ make dry-run + +To run lint, charts, and image targets all at once:: + + $ make all + +To render any documentation that has build steps:: + + $ tox -e docs + + or + + $ make docs + +To build armada's image:: + + $ make run_armada + +To build all images:: + + $ make run_images + To generate sample configuration and policy files needed for Armada deployment, execute (respectively):: diff --git a/entrypoint.sh b/entrypoint.sh index cc7130c3..559e5a3e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,7 +19,7 @@ set -ex CMD="armada" # Define port -PORT=${ARMADA_API_PORT:-8000} +ARMADA_API_PORT=${ARMADA_API_PORT:-8000} # How long uWSGI should wait for each Armada response ARMADA_API_TIMEOUT=${ARMADA_API_TIMEOUT:-"3600"} # Number of uWSGI workers to handle API requests diff --git a/etc/armada/api-paste.ini b/etc/armada/api-paste.ini index 871b7a06..a3c2f770 100644 --- a/etc/armada/api-paste.ini +++ b/etc/armada/api-paste.ini @@ -6,3 +6,4 @@ pipeline = authtoken armada-api [filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory +delay_auth_decision = True diff --git a/tools/armada_image_run.sh b/tools/armada_image_run.sh new file mode 100755 index 00000000..c86cda65 --- /dev/null +++ b/tools/armada_image_run.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Copyright 2018 AT&T Intellectual Property. All other rights reserved. +# +# 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. + +IMAGE=$1 + +set -x + +# Create container +function create { + docker run \ + -v $(pwd)/etc:/etc \ + -d \ + --name armada-api-test \ + -p 127.0.0.1:8000:8000 \ + ${IMAGE} \ + server +} + +# Verify container was successfully created +# If not successful, print out logs +function health_check { + GOOD="HTTP/1.1 204 No Content" + if curl\ + -m 5 \ + -v \ + --silent \ + 127.0.0.1:8000/api/v1.0/health \ + --stderr - \ + | grep "$GOOD" + then + echo "Health Check Success" + exit 0 + else + echo "Failed Health Check" + docker logs armada-api-test + exit 1 + fi +} + +# Remove container +function cleanup { + docker rm -fv armada-api-test +} + +trap cleanup EXIT + +create +health_check diff --git a/tox.ini b/tox.ini index 0b26e37d..f63587ec 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,7 @@ commands = [testenv:docs] commands = + rm -rf doc/build python setup.py build_sphinx [testenv:genconfig]