shamrickus commented on a change in pull request #5351: URL: https://github.com/apache/trafficcontrol/pull/5351#discussion_r539769469
########## File path: .github/actions/tp-e2e-tests/entrypoint.sh ########## @@ -0,0 +1,257 @@ +#!/bin/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. + +fqdn="http://localhost:4444/wd/hub/status" +if ! curl -Lvsk "${fqdn}" >/dev/null 2>&1; then + echo "Selenium not started on ${fqdn}" + exit 1 +fi + +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO tm_user (username, local_passwd, role, tenant_id) VALUES ('admin', 'SCRYPT:16384:8:1:vVw4X6mhoEMQXVGB/ENaXJEcF4Hdq34t5N8lapIjDQEAS4hChfMJMzwwmHfXByqUtjmMemapOPsDQXG+BAX/hA==:vORiLhCm1EtEQJULvPFteKbAX2DgxanPhHdrYN8VzhZBNF81NRxxpo7ig720KcrjH1XFO6BUTDAYTSBGU9KO3Q==', 1, 1)" +# Insert Traffic Vault into server table +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO division(name) VALUES('adivision')" +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO region(name, division) VALUES('aregion', 1)" +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO phys_location(name, short_name, region, address, city, state, zip) VALUES('aloc', 'aloc', 1, 'some place idk', 'Denver', 'CO', '88888')" +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO coordinate(name) VALUES('acoord')" +psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops -c "INSERT INTO cdn(name, domain_name) VALUES('zcdn', 'infra.ciab.test')" +<<QUERY psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops +WITH TYPE AS (SELECT id FROM type WHERE name = 'TC_LOC') +INSERT INTO cachegroup(name, short_name, type, coordinate) +SELECT 'acg', 'acg', TYPE.id, 1 +FROM TYPE +QUERY +<<QUERY psql -d postgresql://traffic_ops:twelve@localhost:5432/traffic_ops +WITH TYPE AS (SELECT id FROM type WHERE name = 'RIAK'), +PROFILE AS (SELECT id FROM profile WHERE name = 'RIAK_ALL'), +STATUS AS (SELECT id FROM status WHERE name = 'ONLINE'), +PHYS AS (SELECT id FROM phys_location WHERE name = 'aloc'), +CDN AS (SELECT id FROM cdn WHERE name = 'zcdn'), +CG AS (SELECT id from cachegroup WHERE name = 'acg') +INSERT INTO server(host_name, domain_name, cachegroup, type, status, profile, phys_location, cdn_id) +SELECT 'trafficvault', 'infra.ciab.test', CG.ID, TYPE.id, STATUS.id, PROFILE.id, PHYS.id, CDN.id +FROM TYPE +JOIN STATUS ON 1=1 +JOIN PROFILE ON 1=1 +JOIN PHYS ON 1=1 +JOIN CDN ON 1=1 +JOIN CG ON 1=1 +QUERY + + +download_go() { + . build/functions.sh + if verify_and_set_go_version; then + return + fi + go_version="$(cat "${GITHUB_WORKSPACE}/GO_VERSION")" + wget -O go.tar.gz "https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz" + echo "Extracting Go ${go_version}..." + <<-'SUDO_COMMANDS' sudo sh + set -o errexit + go_dir="$( + dirname "$( + dirname "$( + realpath "$( + which go + )")")")" + mv "$go_dir" "${go_dir}.unused" + tar -C /usr/local -xzf go.tar.gz + SUDO_COMMANDS + rm go.tar.gz + go version +} + +gray_bg="$(printf '%s%s' $'\x1B' '[100m')"; +red_bg="$(printf '%s%s' $'\x1B' '[41m')"; +yellow_bg="$(printf '%s%s' $'\x1B' '[43m')"; +black_fg="$(printf '%s%s' $'\x1B' '[30m')"; +color_and_prefix() { + color="$1"; + shift; + prefix="$1"; + normal_bg="$(printf '%s%s' $'\x1B' '[49m')"; + normal_fg="$(printf '%s%s' $'\x1B' '[39m')"; + sed "s/^/${color}${black_fg}${prefix}: /" | sed "s/$/${normal_bg}${normal_fg}/"; +} + +ciab_dir="${GITHUB_WORKSPACE}/infrastructure/cdn-in-a-box"; +trafficvault=trafficvault; +start_traffic_vault() { + <<-'/ETC/HOSTS' sudo tee --append /etc/hosts + 172.17.0.1 trafficvault.infra.ciab.test + /ETC/HOSTS + + <<-'BASH_LINES' cat >infrastructure/cdn-in-a-box/traffic_vault/prestart.d/00-0-standalone-config.sh; + TV_FQDN="${TV_HOST}.${INFRA_SUBDOMAIN}.${TLD_DOMAIN}" # Also used in 02-add-search-schema.sh + certs_dir=/etc/ssl/certs; + X509_INFRA_CERT_FILE="${certs_dir}/trafficvault.crt"; + X509_INFRA_KEY_FILE="${certs_dir}/trafficvault.key"; + + # Generate x509 certificate + openssl req -new -x509 -nodes -newkey rsa:4096 -out "$X509_INFRA_CERT_FILE" -keyout "$X509_INFRA_KEY_FILE" -subj "/CN=${TV_FQDN}"; + + # Do not wait for CDN in a Box to generate SSL keys + sed -i '0,/^update-ca-certificates/d' /etc/riak/prestart.d/00-config.sh; + + # Do not try to source to-access.sh + sed -i '/to-access\.sh\|^to-enroll/d' /etc/riak/{prestart.d,poststart.d}/* + BASH_LINES + + DOCKER_BUILDKIT=1 docker build "$ciab_dir" -f "${ciab_dir}/traffic_vault/Dockerfile" -t "$trafficvault" 2>&1 | + color_and_prefix "$gray_bg" "building Traffic Vault"; + echo 'Starting Traffic Vault...'; + docker run \ + --detach \ + --env-file="${ciab_dir}/variables.env" \ + --hostname="${trafficvault}.infra.ciab.test" \ + --name="$trafficvault" \ + --publish=8087:8087 \ + --rm \ + "$trafficvault" \ + /usr/lib/riak/riak-cluster.sh; + docker logs -f "$trafficvault" 2>&1 | + color_and_prefix "$gray_bg" 'Traffic Vault'; +} +start_traffic_vault & + +sudo apt-get install -y --no-install-recommends gettext \ + ruby ruby-dev libc-dev curl \ + chromium-chromedriver postgresql-client \ + gcc musl-dev + +sudo gem update --system && sudo gem install sass compass +sudo npm i -g protractor@^7.0.0 forever bower grunt selenium-webdriver selenium-webdriver +sudo webdriver-manager update --gecko false Review comment: I didn't want to pin the Chrome version, but we should, so I will. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
