This is an automated email from the ASF dual-hosted git repository. dangogh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 40b9fe2e58464199d3c84ddac0f0a58174907d73 Author: Dewayne Richardson <dewr...@apache.org> AuthorDate: Wed Jun 13 14:57:35 2018 -0600 Success with connecting the API Test container to the cdn-in-a-box containers --- traffic_ops/testing/api/docker/Dockerfile | 40 +++++----- traffic_ops/testing/api/docker/docker-compose.yml | 14 +++- traffic_ops/testing/api/docker/run_admin_pl.sh | 54 -------------- traffic_ops/testing/api/docker/run_api_tests.sh | 13 +--- traffic_ops/testing/api/docker/run_traffic_ops.sh | 85 ---------------------- .../testing/api/docker/traffic-ops-test.env | 3 +- 6 files changed, 37 insertions(+), 172 deletions(-) diff --git a/traffic_ops/testing/api/docker/Dockerfile b/traffic_ops/testing/api/docker/Dockerfile index 3f8f18e..7d5952f 100644 --- a/traffic_ops/testing/api/docker/Dockerfile +++ b/traffic_ops/testing/api/docker/Dockerfile @@ -11,18 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -FROM trafficops-perl:latest +FROM golang:1.10.1 MAINTAINER Dewayne Richardson <dewr...@apache.org> -RUN yum -y install vim - -ARG TO_DIR=traffic_ops -ARG API_DOCKER_DIR=. - -ARG TEST_DIR - -ENV TEST_DIR=$TEST_DIR - +RUN pwd ARG DB_NAME ARG DB_SERVER ARG DB_PORT @@ -35,15 +27,27 @@ ENV DB_PORT=$DB_PORT ENV DB_USER=$DB_SERVER ENV DB_PASSWORD=$DB_PASSWORD -#COPY --from=trafficops-perl /opt/traffic_ops /opt/traffic_ops -COPY --from=trafficops-perl /usr/local/go /usr/local/go +ARG SRC_DIR=/go/src +ARG TC_DIR=$SRC_DIR/github.com/apache/incubator-trafficcontrol +ARG TESTING_DIR=$TC_DIR/traffic_ops/testing +ARG TESTING_API_DIR=$TESTING_DIR/api + +#COPY --from=trafficops-perl /opt/traffic_ops/app/bin/traffic_ops_golang /opt/traffic_ops/app/bin/traffic_ops_golang +#COPY --from=trafficops-perl /usr/local/go /usr/local/go + +WORKDIR $TC_DIR -ADD $API_DOCKER_DIR/$TO_RPM / +# Add the lib/go-tc dir +ADD lib lib -ENV PERL5LIB="/opt/traffic_ops/app/lib:/opt/traffic_ops/app/local/lib/perl5" +# Add the dependent dirs (without the cruft) +ADD traffic_ops/traffic_ops_golang traffic_ops/traffic_ops_golang +ADD traffic_ops/vendor traffic_ops/vendor +ADD traffic_ops/testing/api traffic_ops/testing/api +ADD traffic_ops/client traffic_ops/client -WORKDIR /opt/traffic_ops/app -ADD ./run_admin_pl.sh . -RUN ./run_admin_pl.sh +#ADD conf . +WORKDIR $TESTING_API_DIR/v13 +CMD ../docker/run_api_tests.sh -#EXPOSE 60443 +# vi:syntax=Dockerfile diff --git a/traffic_ops/testing/api/docker/docker-compose.yml b/traffic_ops/testing/api/docker/docker-compose.yml index 4b230be..7f39e20 100644 --- a/traffic_ops/testing/api/docker/docker-compose.yml +++ b/traffic_ops/testing/api/docker/docker-compose.yml @@ -18,13 +18,19 @@ #infrastructure/cdn-in-a-box/traffic_ops/ --- -version: '2.1' +version: '3' + +networks: + default: + external: + name: traffic_ops_tcnet services: - api_tests: + trafficops_api_tests: + image: trafficops-api-tests build: - context: . - dockerfile: Dockerfile + context: ../../../.. + dockerfile: traffic_ops/testing/api/docker/Dockerfile args: DB_SERVER: db DB_PORT: 5432 diff --git a/traffic_ops/testing/api/docker/run_admin_pl.sh b/traffic_ops/testing/api/docker/run_admin_pl.sh deleted file mode 100755 index fd44b70..0000000 --- a/traffic_ops/testing/api/docker/run_admin_pl.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -# Script for running the Dockerfile for Traffic Ops. -# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container; -# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container. -# -export GOROOT=/usr/local/go -export GOPATH=/opt/traffic_ops/go -PATH=$PATH:$GOPATH/bin:$GOROOT/bin - -export PGOPTIONS='--client-min-messages=warning' -echo "PERL5LIB: $PERL5LIB" -export USER=root - -cat <<-EOF >/opt/traffic_ops/app/conf/test/database.conf -{ - "description": "Local PostgreSQL database on port 5432", - "dbname": "$DB_NAME", - "hostname": "$DB_SERVER", - "user": "$DB_USER", - "password": "$DB_PASSWORD", - "port": "$DB_PORT", - "ssl": false, - "type": "Pg" -} -EOF - -cat <<-EOF >/opt/traffic_ops/app/db/dbconf.yml -version: "1.0" -name: dbconf.yml - -test: - driver: postgres - open: host=$DB_SERVER port=$DB_PORT user=$DB_USER password=$DB_USER_PASS dbname=$DB_NAME sslmode=disable -EOF - -cd /opt/traffic_ops/app -./db/admin.pl --env=test reset diff --git a/traffic_ops/testing/api/docker/run_api_tests.sh b/traffic_ops/testing/api/docker/run_api_tests.sh index 7dd6613..d6159b3 100755 --- a/traffic_ops/testing/api/docker/run_api_tests.sh +++ b/traffic_ops/testing/api/docker/run_api_tests.sh @@ -24,8 +24,10 @@ source /etc/environment start() { - cd /opt/traffic_ops/testing/api - go get -u golang.org/x/net/publicsuffix && go test -v -cfg=conf/traffic-ops-test.conf + export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH + export GOPATH=/go + go get -u golang.org/x/net/publicsuffix golang.org/x/crypto/scrypt + TODB_HOSTNAME=db TODB_NAME=traffic_ops TO_URL=https://trafficops go test -v -cfg=../conf/traffic-ops-test.conf } @@ -42,11 +44,4 @@ finish() { [[ -n $msg ]] && echo $msg } -trap finish EXIT - -while ! nc $DBHOST $DBPORT </dev/null; do # &>/dev/null; do - echo "waiting for $DBHOST:$DBPORT" - sleep 3 -done - start diff --git a/traffic_ops/testing/api/docker/run_traffic_ops.sh b/traffic_ops/testing/api/docker/run_traffic_ops.sh deleted file mode 100755 index ba26726..0000000 --- a/traffic_ops/testing/api/docker/run_traffic_ops.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -# Script for running the Dockerfile for Traffic Ops. -# The Dockerfile sets up a Docker image which can be used for any new Traffic Ops container; -# This script, which should be run when the container is run (it's the ENTRYPOINT), will configure the container. -# -source /etc/environment - -set -x -export PERL5LIB=/opt/traffic_ops/app/lib:/opt/traffic_ops/app/local/lib/perl5 - -usage() { - echo "Usage: $(basename $0) <test dir> <test env> <host> <port>" - echo " e.g. $(basename $0) ./t test db 5432" -} - -finish() { - local st=$? - [[ $st -ne 0 ]] && echo "Exiting with status $st" - [[ -n $msg ]] && echo $msg -} - -trap finish EXIT - -dbconf=/opt/traffic_ops/app/conf/$TESTENV/database.conf -if [[ ! -f $dbconf ]]; then - usage - msg="$dbconf should be a file" - exit 1 -fi - -while ! nc $DBHOST $DBPORT </dev/null; do # &>/dev/null; do - echo "waiting for $DBHOST:$DBPORT" - sleep 3 -done - -# get dbname, user, password from database.conf; update it with hostname of db container -read dbname user pw <<<$(python -c "import json; d=json.load(open('$dbconf')); d['hostname']='$DBHOST'; d['port']='$DBPORT'; json.dump(d, open('$dbconf', 'w')); print d['dbname'],d['user'],d['password']") || exit $? - -# update dbconf.yml -sed -E -i "s/host=[^ ]+/host=$DBHOST/" /opt/traffic_ops/app/db/dbconf.yml - -# create Postgres Role if doesn't exist -st=$(psql -h$DBHOST -p$DBPORT -Upostgres -tAc "SELECT 1 from pg_roles WHERE rolname='$user'") || exit $? -if [[ $st != 1 ]]; then - psql -h$DBHOST -Upostgres -etAc "CREATE USER $user with LOGIN ENCRYPTED PASSWORD '$pw'" || exit $? -fi - -st=$(psql -h$DBHOST -p$DBPORT -Upostgres -tAc "SELECT 1 FROM pg_database WHERE datname='$dbname'") || exit $? -if [[ $st != 1 ]]; then - createdb -h$DBHOST -p$DBPORT -Upostgres -e --owner $user $dbname || exit $? -fi - -#echo "/opt/traffic_ops/app/db/dbconf.yml" -#cat /opt/traffic_ops/app/db/dbconf.yml - -#echo "/opt/traffic_ops/app/conf/$TESTENV/database.conf" -#cat "/opt/traffic_ops/app/conf/$TESTENV/database.conf" - -export GOROOT=/usr/local/go -export GOPATH=/opt/traffic_ops/go -PATH=$PATH:$GOPATH/bin:$GOROOT/bin - -export PGOPTIONS='--client-min-messages=warning' -echo "PERL5LIB: $PERL5LIB" -export USER=root - -cd /opt/traffic_ops/app -./db/admin.pl --env=$TESTENV reset diff --git a/traffic_ops/testing/api/docker/traffic-ops-test.env b/traffic_ops/testing/api/docker/traffic-ops-test.env index a7af591..bdd5c7b 100644 --- a/traffic_ops/testing/api/docker/traffic-ops-test.env +++ b/traffic_ops/testing/api/docker/traffic-ops-test.env @@ -18,8 +18,7 @@ TO_URL=https://localhost:8443 TO_USER=admin TO_USER_PASSWORD=twelve SSL_INSECURE=true -DB_NAME=to_test +DB_NAME=traffic_ops DB_USER=traffic_ops -DB_SERVER=traffic_ops_db_1 DB_PASSWORD=twelve DB_PORT=5432 -- To stop receiving notification emails like this one, please contact dang...@apache.org.