Skip to content

Commit

Permalink
Fixing remote integ test for windows by using awk instead of python (#…
Browse files Browse the repository at this point in the history
…1404)

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit d6e7636)

Co-authored-by: Nishant Goel <[email protected]>
  • Loading branch information
1 parent d154604 commit f4af360
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions scripts/integtest.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,48 @@ then
exit 1
fi

data=$(python3 -c "import json; cluster=$ENDPOINT_LIST ; data_nodes=cluster; print(data_nodes[0][\"data_nodes\"][0][\"endpoint\"],':',data_nodes[0][\"data_nodes\"][0][\"port\"],':',data_nodes[0][\"data_nodes\"][0][\"transport\"],',',data_nodes[1][\"data_nodes\"][0][\"endpoint\"],':',data_nodes[1][\"data_nodes\"][0][\"port\"],':',data_nodes[1][\"data_nodes\"][0][\"transport\"])" | tr -d "[:blank:]")
extract_values() {
local cluster_name="$1"
local field="$2"

echo "$ENDPOINT_LIST" | awk -v cluster="$cluster_name" -v field="$field" '
BEGIN { RS=","; FS=":" }
$1 ~ "\"cluster_name\"" && $2 ~ "\"" cluster "\"" {
while (getline) {
if ($1 ~ "\"" field "\"") {
gsub(/"/, "", $2)
gsub(/ /, "", $2)
print $2
exit
}
}
}
' | tr -d '{}'
}

# Extract values for leader cluster
leader_endpoint=$(extract_values "leader" "endpoint")
leader_port=$(extract_values "leader" "port")
leader_transport=$(extract_values "leader" "transport")

# Extract values for follower cluster
follower_endpoint=$(extract_values "follower" "endpoint")
follower_port=$(extract_values "follower" "port")
follower_transport=$(extract_values "follower" "transport")

# Print extracted data
echo "Leader Endpoint: $leader_endpoint"
echo "Leader Port: $leader_port"
echo "Leader Transport: $leader_transport"
echo "Follower Endpoint: $follower_endpoint"
echo "Follower Port: $follower_port"
echo "Follower Transport: $follower_transport"

leader=$(echo $data | cut -d ',' -f1 | cut -d ':' -f1,2 )
follower=$(echo $data | cut -d ',' -f2 | cut -d ':' -f1,2 )
echo "leader: $leader"
echo "follower: $follower"

# Get number of nodes, assuming both leader and follower have same number of nodes
numNodes=$((${follower##*:} - ${leader##*:}))
numNodes=$((${follower_port} - ${leader_port}))
echo "numNodes: $numNodes"

LTRANSPORT_PORT=$(echo $data | cut -d ',' -f1 | cut -d ':' -f1,3 )
FTRANSPORT_PORT=$(echo $data | cut -d ',' -f2 | cut -d ':' -f1,3 )
echo "LTRANSPORT_PORT: $LTRANSPORT_PORT"
echo "FTRANSPORT_PORT: $FTRANSPORT_PORT"

eval "./gradlew integTestRemote -Dleader.http_host=\"$leader\" -Dfollower.http_host=\"$follower\" -Dfollower.transport_host=\"$FTRANSPORT_PORT\" -Dleader.transport_host=\"$LTRANSPORT_PORT\" -Dsecurity_enabled=\"$SECURITY_ENABLED\" -Duser=\"$USERNAME\" -Dpassword=\"$PASSWORD\" -PnumNodes=$numNodes --console=plain "
echo './gradlew integTestRemote -Dleader.http_host='"$leader_endpoint:$leader_port"' -Dfollower.http_host='"$follower_endpoint:$follower_port"' -Dfollower.transport_host='"$follower_endpoint:$follower_transport"' -Dleader.transport_host='"$leader_endpoint:$leader_transport"' -Dsecurity_enabled='"$SECURITY_ENABLED"' -Duser='"$USERNAME"' -Dpassword='"$PASSWORD"' -PnumNodes='"$numNodes"' --console=plain'
./gradlew integTestRemote -Dleader.http_host=$leader_endpoint:$leader_port -Dfollower.http_host=$follower_endpoint:$follower_port -Dfollower.transport_host=$follower_endpoint:$follower_transport -Dleader.transport_host=$leader_endpoint:$leader_transport -Dsecurity_enabled=$SECURITY_ENABLED -Duser=$USERNAME -Dpassword=$PASSWORD -PnumNodes=$numNodes --console=plain

else
# Single cluster
Expand Down

0 comments on commit f4af360

Please sign in to comment.