You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/11/10 20:02:39 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #4763: Rewrote postinstall to Python (3.6+)

ocket8888 commented on a change in pull request #4763:
URL: https://github.com/apache/trafficcontrol/pull/4763#discussion_r520839913



##########
File path: traffic_ops/install/bin/postinstall.test.sh
##########
@@ -0,0 +1,424 @@
+#!/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.
+
+set -e;
+
+if [[ ! -x /usr/bin/python3 ]]; then
+	echo "Python 3.6+ is required to run - or test - postinstall.py" >&2;
+	exit 1;
+fi
+
+ROOT_DIR="$(mktemp -d)";
+
+trap 'rm -rf $ROOT_DIR' EXIT;
+
+mkdir -p "$ROOT_DIR/etc/pki/tls/certs";
+mkdir "$ROOT_DIR/etc/pki/tls/private";
+mkdir -p "$ROOT_DIR/opt/traffic_ops/app/public/routing";
+mkdir "$ROOT_DIR/opt/traffic_ops/app/db";
+mkdir -p "$ROOT_DIR/opt/traffic_ops/app/conf/production";
+echo "{\"hypnotoad\":{\"listen\":[\"https://[::]:60443?cert=$ROOT_DIR/etc/pki/tls/certs/localhost.crt&key=$ROOT_DIR/etc/pki/tls/private/localhost.key\"]}}" > "$ROOT_DIR/opt/traffic_ops/app/conf/cdn.conf";

Review comment:
       Doing that causes the test to fail to find `users.json`:
   ```diff
   diff --git a/traffic_ops/install/bin/postinstall.test.sh b/traffic_ops/install/bin/postinstall.test.sh
   index d98c11645..cb8405c12 100755
   --- a/traffic_ops/install/bin/postinstall.test.sh
   +++ b/traffic_ops/install/bin/postinstall.test.sh
   @@ -32,7 +32,15 @@ mkdir "$ROOT_DIR/etc/pki/tls/private";
    mkdir -p "$ROOT_DIR/opt/traffic_ops/app/public/routing";
    mkdir "$ROOT_DIR/opt/traffic_ops/app/db";
    mkdir -p "$ROOT_DIR/opt/traffic_ops/app/conf/production";
   -echo "{\"hypnotoad\":{\"listen\":[\"https://[::]:60443?cert=$ROOT_DIR/etc/pki/tls/certs/localhost.crt&key=$ROOT_DIR/etc/pki/tls/private/localhost.key\"]}}" > "$ROOT_DIR/opt/traffic_ops/app/conf/cdn.conf";
   +cat > "$ROOT_DIR/opt/traffic_ops/app/conf/cdn.conf" <<EOF
   +{
   +       "hypnotoad": {
   +               "listen": [
   +                       "https://[::]:60443?cert=$ROOT_DIR/etc/pki/tls/certs/localhost.crt&key=$ROOT_DIR/etc/pki/tls/private/localhost.key"
   +               ]
   +       }
   +}
   +EOF;
    mkdir -p "$ROOT_DIR/opt/traffic_ops/install/data/json";
    mkdir "$ROOT_DIR/opt/traffic_ops/install/bin";
   ```
   
   causes:
   
   ```
   Error loading users.json file: [Errno 2] No such file or directory: '/tmp/tmp.7vg08w3Ow2/opt/traffic_ops/install/data/json/users.json'
   ```
   
   I don't know how or why but it does




----------------------------------------------------------------
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:
users@infra.apache.org