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 4b5a32c59f0eb1dca6ce1521c27c0f50a43e01e0
Author: Dewayne Richardson <dewr...@apache.org>
AuthorDate: Wed Jun 13 07:46:23 2018 -0600

    refactored the Dockerfiles for the API Tests
---
 .../api/docker/{Dockerfile-to-test => Dockerfile}  | 39 +++++-------
 traffic_ops/testing/api/docker/Dockerfile-to-base  | 74 ----------------------
 traffic_ops/testing/api/docker/docker-compose.yml  | 39 ++----------
 traffic_ops/testing/api/docker/run_admin_pl.sh     | 54 ++++++++++++++++
 .../testing/api/docker/traffic-ops-test.env        | 11 ++--
 5 files changed, 79 insertions(+), 138 deletions(-)

diff --git a/traffic_ops/testing/api/docker/Dockerfile-to-test 
b/traffic_ops/testing/api/docker/Dockerfile
similarity index 58%
rename from traffic_ops/testing/api/docker/Dockerfile-to-test
rename to traffic_ops/testing/api/docker/Dockerfile
index 63d3597..5f48267 100644
--- a/traffic_ops/testing/api/docker/Dockerfile-to-test
+++ b/traffic_ops/testing/api/docker/Dockerfile
@@ -11,38 +11,31 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-#FROM centos:7.2.1511
-FROM docker_to_base:latest
+FROM trafficops-perl:latest
 MAINTAINER Dewayne Richardson <dewr...@apache.org>
 
 ARG TO_DIR=traffic_ops
-ARG TESTENV=$TESTENV
+ARG TEST_ENV=$TEST_ENV
 ARG API_DOCKER_DIR=traffic_ops/testing/api/docker
-# ignore this if it fails
-#RUN rm -rf /root/.cpan* 2>/dev/null || true
 
-ARG TESTDIR
-ARG TESTENV
-ENV TESTDIR=$TESTDIR
-ENV TESTENV=$TESTENV
-ARG DBHOST
-ARG DBPORT
-ENV DBHOST=$DBHOST
-ENV DBPORT=$DBPORT
-#ADD $API_DOCKER_DIR/run_traffic_ops.sh /opt/traffic_ops/app
+ARG TEST_DIR
+ARG TEST_ENV
+ENV TEST_DIR=$TEST_DIR
+ENV TEST_ENV=$TEST_ENV
+ARG DB_SERVER
+ARG DB_PORT
+ENV DB_SERVER=$DB_SERVER
+ENV DB_PORT=$DB_PORT
 
-ARG TO_RPM=traffic_ops-2.2.0-7398.7bb32b09.el7.x86_64.rpm
-ADD $API_DOCKER_DIR/$TO_RPM /
-ADD $API_DOCKER_DIR/run_traffic_ops.sh /
-#WORKDIR /
-#RUN yum -y install $TO_RPM
+#COPY --from=trafficops-perl /opt/traffic_ops /opt/traffic_ops
+COPY --from=trafficops-perl /usr/local/go /usr/local/go
 
-#ADD $API_DOCKER_DIR/local /opt/traffic_ops/app
-WORKDIR /opt/traffic_ops/app
+ADD $API_DOCKER_DIR/$TO_RPM /
+ADD $API_DOCKER_DIR/run_admin_pl.sh /
 
 ENV PERL5LIB="/opt/traffic_ops/app/lib:/opt/traffic_ops/app/local/lib/perl5"
 
-RUN POSTGRES_HOME=/usr/pgsql-9.6 carton
-CMD /run_traffic_ops.sh
+WORKDIR /opt/traffic_ops/app
+RUN ./db/admin.pl --env=$TEST_ENV reset
 
 #EXPOSE 60443
diff --git a/traffic_ops/testing/api/docker/Dockerfile-to-base 
b/traffic_ops/testing/api/docker/Dockerfile-to-base
deleted file mode 100644
index 7718efa..0000000
--- a/traffic_ops/testing/api/docker/Dockerfile-to-base
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# 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.
-#
-#FROM centos:7.2.1511
-FROM centos:7
-MAINTAINER Dan Kirkwood <dang...@apache.org>
-
-RUN yum -y install \
-        
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
-
-RUN yum -y install \
-        epel-release \
-        vim \
-        cpanminus \
-        expat-devel \
-        gcc-c++ \
-        libcurl \
-        libcurl-devel \
-        libidn-devel \
-        libpcap-devel \
-        mkisofs \
-        nmap-ncat \
-        openssl-devel \
-        perl \
-        perl-App-cpanminus \
-        perl-DBD-Pg \
-        perl-DBI \
-        perl-Digest-SHA1 \
-        perl-JSON \
-        perl-TermReadKey \
-        perl-Test-CPAN-Meta \
-        perl-WWW-Curl \
-        perl-core \
-        perl-libwww-perl \
-        perl-Crypt-ScryptKDF \
-        postgresql96 \
-        postgresql96-devel && \
-        yum clean all
-
-RUN cpanm -n Carton
-
-ARG TO_DIR=traffic_ops
-ARG API_DOCKER_DIR=traffic_ops/testing/api/docker
-
-ARG TO_RPM=traffic_ops-2.2.0-7398.7bb32b09.el7.x86_64.rpm
-ADD $API_DOCKER_DIR/$TO_RPM /
-WORKDIR /
-RUN yum -y install $TO_RPM
-
-ADD $TO_DIR/install/bin/install_goose.sh /
-ADD $TO_DIR/install/bin/install_go.sh /
-RUN /install_go.sh
-RUN /install_goose.sh
-
-
-#ADD $API_DOCKER_DIR/local /opt/traffic_ops/app
-WORKDIR /opt/traffic_ops/app
-
-RUN POSTGRES_HOME=/usr/pgsql-9.6 carton
-
-CMD bash -c 'echo "Completed"'
-#CMD bash -c 'mv -v local /'
-
-#EXPOSE 60443
diff --git a/traffic_ops/testing/api/docker/docker-compose.yml 
b/traffic_ops/testing/api/docker/docker-compose.yml
index daa8b24..19ef922 100644
--- a/traffic_ops/testing/api/docker/docker-compose.yml
+++ b/traffic_ops/testing/api/docker/docker-compose.yml
@@ -15,49 +15,18 @@
 # specific language governing permissions and limitations
 # under the License.
 ---
-version: '2'
-
-volumes:
-  incubator-trafficcontrol:
-  traffic_ops:
-  conf:
+version: '3.6'
 
 services:
-  db:
-    image: postgres:9.6.6
-
-  to_base:
-    build:
-      context: ../../../..
-      dockerfile: traffic_ops/testing/api/docker/Dockerfile-to-base
-    volumes:
-      - traffic_ops:/opt/traffic_ops
-    links:
-      - db
-
-  to_test:
-    build:
-      context: ../../../..
-      dockerfile: traffic_ops/testing/api/docker/Dockerfile-to-test
-      args:
-        TESTENV: test
-        DBHOST: db
-        DBPORT: 5432
-    links:
-      - db
-
   api_tests:
     build:
       context: ../../../..
-      dockerfile: traffic_ops/testing/api/docker/Dockerfile-api-tests
+      dockerfile: traffic_ops/testing/api/docker/Dockerfile
       args:
-        DBHOST: db
-        DBPORT: 5432
+        DB_SERVER: db
+        DB_PORT: 5432
     env_file:
       - traffic-ops-test.env
     volumes:
       - incubator-trafficcontrol:/incubator-trafficcontrol
       - conf:/conf
-    links:
-      - db
-      - to_test
diff --git a/traffic_ops/testing/api/docker/run_admin_pl.sh 
b/traffic_ops/testing/api/docker/run_admin_pl.sh
new file mode 100755
index 0000000..438a6ed
--- /dev/null
+++ b/traffic_ops/testing/api/docker/run_admin_pl.sh
@@ -0,0 +1,54 @@
+#!/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_ENV reset
diff --git a/traffic_ops/testing/api/docker/traffic-ops-test.env 
b/traffic_ops/testing/api/docker/traffic-ops-test.env
index ef1f0de..a7af591 100644
--- a/traffic_ops/testing/api/docker/traffic-ops-test.env
+++ b/traffic_ops/testing/api/docker/traffic-ops-test.env
@@ -18,9 +18,8 @@ TO_URL=https://localhost:8443
 TO_USER=admin
 TO_USER_PASSWORD=twelve
 SSL_INSECURE=true
-TODB_NAME=to_test
-TODB_USER=traffic_ops
-TODB_HOSTNAME=localhost
-TODB_PASSWORD=twelve
-TODB_PORT=5432
-SESSION_TIMEOUT_IN_SECS=10
+DB_NAME=to_test
+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.

Reply via email to