Addressing PR concerns

Signed-off-by: gberl002 <geoff.berl@netfoundry.io>
This commit is contained in:
gberl002
2022-11-29 16:39:30 -05:00
parent af1daff190
commit bd74580f72
4 changed files with 16 additions and 7 deletions
+4 -1
View File
@@ -29,7 +29,10 @@ if [[ -f "${initFile}" ]]; then
fi
# give the controller scripts time to start and create the ziti environment file if running in docker compose
until $(test -f "${ZITI_HOME}/ziti.env"); do echo "waiting for ziti.env..."; sleep 2; done
until $(test -f "${ZITI_HOME}/ziti.env"); do echo "waiting for ziti.env..."; sleep 1; done
# Pause shortly to avoid the intermittent error of reading the file before it's completely done being written to.
sleep 1
. "${ZITI_SCRIPTS}/ziti-cli-functions.sh"
@@ -291,10 +291,11 @@ function _portCheck {
elif [[ -n "$BASH_VERSION" ]]; then
envVarValue="${!envVar}"
else
echo -e "Unknown/Unsupported shell, cannot check port status"
return 1
echo -e "$(YELLOW "Unknown/Unsupported shell, cannot verify availability of ${2-}'s intended port, proceed with caution")"
return 0
fi
echo -e "Checking if ${2-}'s port (${envVarValue}) is available"
portCheckResult=$(lsof -w -i :"${envVarValue}" 2> /dev/null)
if [[ "${portCheckResult}" != "" ]]; then # Controller management plane
echo -e "$(RED " ")"
@@ -510,8 +511,11 @@ function ziti_expressConfiguration {
returnCnt=$((returnCnt + $?))
_portCheck "ZITI_CTRL_MGMT_PORT" "Controller Management Plane"
returnCnt=$((returnCnt + $?))
_portCheck "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" "Router Listener Bind Port"
returnCnt=$((returnCnt + $?))
if [[ "${ZITI_EDGE_ROUTER_LISTENER_BIND_PORT-}" != "" ]]; then
# This port can be explicitly set but is not always, only check if set
_portCheck "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" "Router Listener Bind Port"
returnCnt=$((returnCnt + $?))
fi
if [[ "returnCnt" -gt "0" ]]; then return 1; fi
#checkHostsFile
@@ -191,7 +191,7 @@ func TestBlankEdgeRouterNameBecomesHostname(t *testing.T) {
}
func TestDefaultZitiEdgeRouterListenerBindPort(t *testing.T) {
expectedDefaultPort := "10080"
expectedDefaultPort := TEST_ROUTER_LISTENER_PORT
// Make sure the related env vars are unset
_ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT")
@@ -9,6 +9,8 @@ import (
"time"
)
var TEST_ROUTER_LISTENER_PORT = 10080
func TestExecuteCreateConfigRouterFabricHasNonBlankTemplateValues(t *testing.T) {
routerName := "MyFabricRouter"
expectedNonEmptyStringFields := []string{".Router.Listener.BindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Hostname", ".Router.Edge.Port"}
@@ -112,7 +114,7 @@ func TestFabricRouterOutputPathDoesNotExist(t *testing.T) {
}
func TestDefaultZitiFabricRouterListenerBindPort(t *testing.T) {
expectedDefaultPort := "10080"
expectedDefaultPort := TEST_ROUTER_LISTENER_PORT
// Make sure the related env vars are unset
_ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT")