diff options
author | liamfallon <liam.fallon@est.tech> | 2022-09-01 12:05:47 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2022-09-05 10:19:02 +0100 |
commit | faac45b578a29078700b5ea003c69cedc1a17b5f (patch) | |
tree | f2a079358441401e50c9933255122796b2134ea6 /csit/wait_for_port.sh | |
parent | ff82245b200616cf30a6f6cd4d1e5305ae3d90ef (diff) |
Convert CSIT tests to use HTTP rather than HTTPS
This commit converts the CSITs from HTTPS to HTTP. It also does some
refactoring and didying up on the CSIT environment.
Issue-ID: POLICY-4338
Change-Id: Ie19908a8d2a457df3ae5f4e490d5528889f395c8
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'csit/wait_for_port.sh')
-rwxr-xr-x | csit/wait_for_port.sh | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/csit/wait_for_port.sh b/csit/wait_for_port.sh index 0eeb1c9b..0a9adc3a 100755 --- a/csit/wait_for_port.sh +++ b/csit/wait_for_port.sh @@ -1,6 +1,7 @@ #!/bin/sh # ============LICENSE_START==================================================== # Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 2022 Nordix Foundation. # ============================================================================= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,35 +18,64 @@ # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END====================================================== +usage() { + echo args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ... >&2 + exit 1 +} + tmout=300 cmd= -while getopts c:t: opt; do +while getopts c:t: opt +do case "$opt" in - c) cmd="$OPTARG" ;; - t) tmout="$OPTARG" ;; + c) + cmd="$OPTARG" + ;; + + t) + tmout="$OPTARG" + ;; + + *) + usage + ;; esac done -nargs=$(expr $OPTIND - 1) -shift $nargs -even_args=$(expr $# % 2) -if [ $# -lt 2 -o $even_args -ne 0 ]; then - echo "args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ..." >&2 - exit 1 +nargs=$((OPTIND-1)) +shift "$nargs" + +even_args=$(($#%2)) +if [ $# -lt 2 ] || [ "$even_args" -ne 0 ] +then + usage fi -while [ $# -ge 2 ]; do - export host=$1 - export port=$2 +while [ $# -ge 2 ] +do + export host="$1" + export port="$2" shift shift echo "Waiting for $host port $port..." - timeout $tmout sh -c 'until nc -vz "$host" "$port"; do echo -n "."; - sleep 1; done' - rc=$? - if [ $rc != 0 ]; then + while [ "$tmout" -gt 0 ] + do + nc -vz "$host" "$port" + rc=$? + + if [ $rc -eq 0 ] + then + break + else + tmout=$((tmout-1)) + sleep 1 + fi + done + + if [ $rc -ne 0 ] + then echo "$host port $port cannot be reached" exit $rc fi |