From 93877bbcc36161005af5218f1566e55965654716 Mon Sep 17 00:00:00 2001 From: Bryan Strassner Date: Fri, 8 Dec 2017 20:49:22 -0600 Subject: [PATCH] Update makefile with run commands Set up and do a rudimentary test of the images created by the shipyard project to see if the images are okish. Change-Id: I1f1c8fbcfeeafff66764ae99a176ff6a6766edce --- Makefile | 11 +++++ images/airflow/Dockerfile | 5 +++ .../airflow/script/airflow_start_service.sh | 11 +++++ tools/airflow_image_run.sh | 34 ++++++++++++++ tools/resources/shipyard.conf | 42 +++++++++++++++++ tools/shipyard_image_run.sh | 45 +++++++++++++++++++ 6 files changed, 148 insertions(+) create mode 100755 tools/airflow_image_run.sh create mode 100644 tools/resources/shipyard.conf create mode 100755 tools/shipyard_image_run.sh diff --git a/Makefile b/Makefile index b0d93bb2..be7ebb73 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,19 @@ dry-run: clean .PHONY: docs docs: clean build_docs +.PHONY: run_images +run_images: run_shipyard run_airflow + # Make targets intended for use by the primary targets above. +.PHONY: run_shipyard +run_shipyard: clean build_shipyard + tools/shipyard_image_run.sh $(IMAGE_PREFIX) $(SHIPYARD_IMAGE_NAME) $(IMAGE_TAG) + +.PHONY: run_airflow +run_airflow: clean build_airflow + tools/airflow_image_run.sh $(IMAGE_PREFIX) $(AIRFLOW_IMAGE_NAME) $(IMAGE_TAG) + .PHONY: build_airflow build_airflow: docker build -t $(IMAGE_PREFIX)/$(AIRFLOW_IMAGE_NAME):$(IMAGE_TAG) images/airflow/ diff --git a/images/airflow/Dockerfile b/images/airflow/Dockerfile index 77f713e7..eabb250c 100644 --- a/images/airflow/Dockerfile +++ b/images/airflow/Dockerfile @@ -61,6 +61,11 @@ RUN set -ex && \ # Install Armada libraries COPY ./requirements.txt /tmp/ RUN pip3 install -r /tmp/requirements.txt + +# Note - removing snakebite (python 2 vs. 3). See: +# https://github.com/puckel/docker-airflow/issues/77 +RUN pip3 uninstall -y snakebite || true + RUN pip3 install -e git://github.com/att-comdev/drydock.git#egg=drydock_provisioner RUN pip3 install -e git://github.com/att-comdev/armada.git#egg=armada diff --git a/images/airflow/script/airflow_start_service.sh b/images/airflow/script/airflow_start_service.sh index c8b20114..27437cde 100644 --- a/images/airflow/script/airflow_start_service.sh +++ b/images/airflow/script/airflow_start_service.sh @@ -41,6 +41,17 @@ elif [[ $cmd == *scheduler* ]]; then airflow_cmd="/usr/bin/python3 /usr/local/bin/airflow scheduler $2 $3" eval $airflow_cmd done +elif [[ $cmd == 'quicktest' ]]; then + test_cmd="/usr/bin/python3 /usr/local/bin/airflow initdb" + eval $test_cmd + test_cmd2="/usr/bin/python3 /usr/local/bin/airflow webserver -p 8080 &" + eval $test_cmd2 + test_cmd3="airflow run example_bash_operator runme_0 2015-01-01" + eval $test_cmd3 + test_cmd4="airflow backfill example_bash_operator -s 2015-01-01 -e 2015-01-02" + eval $test_cmd4 + test_cmd5="airflow dag_state example_bash_operator 2015-01-01" + eval $test_cmd5 else echo "Invalid Command!" exit 0 diff --git a/tools/airflow_image_run.sh b/tools/airflow_image_run.sh new file mode 100755 index 00000000..082aff44 --- /dev/null +++ b/tools/airflow_image_run.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2017 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. +# +set -x + +IMAGE_PREFIX=$1 +AIRFLOW_IMAGE_NAME=$2 +IMAGE_TAG=$3 + +TEST_RESP="$(docker run \ + -p 8080:8080 \ + --name airflow_test ${IMAGE_PREFIX}/${AIRFLOW_IMAGE_NAME}:${IMAGE_TAG} \ + quicktest)" + +docker stop airflow_test +docker rm airflow_test + +if [[ ${TEST_RESP:(-7)} == "success" ]]; then + exit 0 +else + exit 1 +fi diff --git a/tools/resources/shipyard.conf b/tools/resources/shipyard.conf new file mode 100644 index 00000000..c7b716aa --- /dev/null +++ b/tools/resources/shipyard.conf @@ -0,0 +1,42 @@ +# A fake configuration file with default/fake values specified for use in +# basic testing of the Shipyard image +[armada] +service_type = armada +[base] +postgresql_airflow_db = postgresql+psycopg2://airflow:password@postgresql.ucp.svc.cluster.local:5432/airflow +postgresql_db = postgresql+psycopg2://shipyard:password@postgresql.ucp.svc.cluster.local:5432/shipyard +web_server = http://airflow-web-int.ucp.svc.cluster.local:8080/ +upgrade_db = false +[deckhand] +service_type = deckhand +[drydock] +cluster_join_check_backoff_time = 120 +deploy_node_query_interval = 30 +deploy_node_task_timeout = 3600 +prepare_node_query_interval = 30 +prepare_node_task_timeout = 1800 +prepare_site_query_interval = 10 +prepare_site_task_timeout = 120 +service_type = physicalprovisioner +verify_site_query_interval = 10 +verify_site_task_timeout = 60 +[healthcheck] +endpoint = /api/v1.0/health +schema = http +[keystone_authtoken] +auth_section = keystone_authtoken +auth_type = password +auth_uri = http://keystone-api.ucp.svc.cluster.local:80/v3 +auth_url = http://keystone-api.ucp.svc.cluster.local:80/v3 +auth_version = v3 +delay_auth_decision = true +memcache_secret_key = secret +memcache_security_strategy = None +memcached_servers = memcached.ucp.svc.cluster.local:11211 +password = password +project_domain_name = default +project_name = service +user_domain_name = default +username = shipyard +[shipyard] +service_type = shipyard \ No newline at end of file diff --git a/tools/shipyard_image_run.sh b/tools/shipyard_image_run.sh new file mode 100755 index 00000000..f45d21e9 --- /dev/null +++ b/tools/shipyard_image_run.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2017 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. +# +set -x + +IMAGE_PREFIX=$1 +SHIPYARD_IMAGE_NAME=$2 +IMAGE_TAG=$3 + +# Collect necessary files and run shipyard image in docker +mkdir -p build/.tmprun/etc +cp $PWD/etc/shipyard/api-paste.ini build/.tmprun/etc +cp $PWD/tools/resources/shipyard.conf build/.tmprun/etc +docker run \ + -v $PWD/build/.tmprun/etc:/etc/shipyard \ + -p 9000:9000 \ + --name shipyard_test ${IMAGE_PREFIX}/${SHIPYARD_IMAGE_NAME}:${IMAGE_TAG} \ + & + +sleep 5 + +RESULT="$(curl -i 'http://127.0.0.1:9000/versions' | tr '\r' '\n' | head -1)" + +docker stop shipyard_test +docker rm shipyard_test +rm -r build/.tmprun + +GOOD="HTTP/1.1 200 OK" +if [[ ${RESULT} == ${GOOD} ]]; then + exit 0 +else + exit 1 +fi