tests/e2e: quiet grep output to pollute the terminal a little less
This commit is contained in:
parent
924fdfe586
commit
a278725078
@ -117,7 +117,7 @@ check_volume_exists() {
|
|||||||
|
|
||||||
check_cluster_token_exist() {
|
check_cluster_token_exist() {
|
||||||
[ -n "$EXE" ] || abort "EXE is not defined"
|
[ -n "$EXE" ] || abort "EXE is not defined"
|
||||||
$EXE cluster get "$1" --token | grep "TOKEN" >/dev/null 2>&1
|
$EXE cluster get "$1" --token | grep -q "TOKEN" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_pod_running_by_label() {
|
wait_for_pod_running_by_label() {
|
||||||
@ -174,11 +174,11 @@ exec_in_node() {
|
|||||||
docker_assert_container_label() {
|
docker_assert_container_label() {
|
||||||
# $1 = container/node name
|
# $1 = container/node name
|
||||||
# $2 = label to assert
|
# $2 = label to assert
|
||||||
docker inspect --format '{{ range $k, $v := .Config.Labels }}{{ printf "%s=%s\n" $k $v }}{{ end }}' "$1" | grep -E "^$2$"
|
docker inspect --format '{{ range $k, $v := .Config.Labels }}{{ printf "%s=%s\n" $k $v }}{{ end }}' "$1" | grep -qE "^$2$"
|
||||||
}
|
}
|
||||||
|
|
||||||
k3s_assert_node_label() {
|
k3s_assert_node_label() {
|
||||||
# $1 = node name
|
# $1 = node name
|
||||||
# $2 = label to assert
|
# $2 = label to assert
|
||||||
kubectl get node "$1" --output go-template='{{ range $k, $v := .metadata.labels }}{{ printf "%s=%s\n" $k $v }}{{ end }}' | grep -E "^$2$"
|
kubectl get node "$1" --output go-template='{{ range $k, $v := .metadata.labels }}{{ printf "%s=%s\n" $k $v }}{{ end }}' | grep -qE "^$2$"
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ trap finish EXIT
|
|||||||
|
|
||||||
# wait for the runner container to be up or exit early
|
# wait for the runner container to be up or exit early
|
||||||
TIMEOUT=0
|
TIMEOUT=0
|
||||||
until docker inspect "$k3de2e" | jq ".[0].State.Running" && docker logs "$k3de2e" 2>&1 | grep -i "API listen on /var/run/docker.sock"; do
|
until docker inspect "$k3de2e" | jq ".[0].State.Running" && docker logs "$k3de2e" 2>&1 | grep -qi "API listen on /var/run/docker.sock"; do
|
||||||
if [[ $TIMEOUT -eq $RUNNER_START_TIMEOUT ]]; then
|
if [[ $TIMEOUT -eq $RUNNER_START_TIMEOUT ]]; then
|
||||||
echo "Failed to start E2E Runner Container in $RUNNER_START_TIMEOUT seconds"
|
echo "Failed to start E2E Runner Container in $RUNNER_START_TIMEOUT seconds"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -19,7 +19,7 @@ info "Checking we have access to both clusters..."
|
|||||||
check_clusters "c1" "c2" || failed "error checking cluster"
|
check_clusters "c1" "c2" || failed "error checking cluster"
|
||||||
|
|
||||||
info "Checking cluster env var with escaped @ signs..."
|
info "Checking cluster env var with escaped @ signs..."
|
||||||
docker exec k3d-c1-server-0 env | grep -E '^TEST_VAR=user@pass\\$' || failed "Failed to lookup proper env var in container"
|
docker exec k3d-c1-server-0 env | grep -qE '^TEST_VAR=user@pass\\$' || failed "Failed to lookup proper env var in container"
|
||||||
|
|
||||||
info "Check k3s token retrieval"
|
info "Check k3s token retrieval"
|
||||||
check_cluster_token_exist "c1" || failed "could not find cluster token c1"
|
check_cluster_token_exist "c1" || failed "could not find cluster token c1"
|
||||||
|
@ -39,7 +39,7 @@ check_multi_node "$clustername" 5 || failed "failed to verify number of nodes"
|
|||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
info "Ensuring that environment variables are present in the node containers as set in the config (with comma)"
|
info "Ensuring that environment variables are present in the node containers as set in the config (with comma)"
|
||||||
exec_in_node "k3d-$clustername-server-0" "env" | grep "bar=baz,bob" || failed "Expected env var 'bar=baz,bob' is not present in node k3d-$clustername-server-0"
|
exec_in_node "k3d-$clustername-server-0" "env" | grep -q "bar=baz,bob" || failed "Expected env var 'bar=baz,bob' is not present in node k3d-$clustername-server-0"
|
||||||
|
|
||||||
## Container Labels
|
## Container Labels
|
||||||
info "Ensuring that container labels have been set as stated in the config"
|
info "Ensuring that container labels have been set as stated in the config"
|
||||||
@ -55,8 +55,8 @@ $EXE node list "k3d-$clustername-registry" || failed "Expected k3d-$clustername-
|
|||||||
|
|
||||||
## merged registries.yaml
|
## merged registries.yaml
|
||||||
info "Ensuring, that the registries.yaml file contains both registries"
|
info "Ensuring, that the registries.yaml file contains both registries"
|
||||||
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -i "my.company.registry" || failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
|
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -qi "my.company.registry" || failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
|
||||||
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -i "k3d-$clustername-registry" || failed "Expected 'k3d-$clustername-registry' to be in the /etc/rancher/k3s/registries.yaml"
|
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -qi "k3d-$clustername-registry" || failed "Expected 'k3d-$clustername-registry' to be in the /etc/rancher/k3s/registries.yaml"
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ check_multi_node "$clustername" 6 || failed "failed to verify number of nodes"
|
|||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
info "Ensuring that environment variables are present in the node containers as set in the config and overrides"
|
info "Ensuring that environment variables are present in the node containers as set in the config and overrides"
|
||||||
exec_in_node "k3d-$clustername-server-0" "env" | grep "bar=baz" || failed "Expected env var 'bar=baz' is not present in node k3d-$clustername-server-0"
|
exec_in_node "k3d-$clustername-server-0" "env" | grep -q "bar=baz" || failed "Expected env var 'bar=baz' is not present in node k3d-$clustername-server-0"
|
||||||
exec_in_node "k3d-$clustername-agent-1" "env" | grep "x=y" || failed "Expected env var 'x=y' is not present in node k3d-$clustername-agent-1"
|
exec_in_node "k3d-$clustername-agent-1" "env" | grep -q "x=y" || failed "Expected env var 'x=y' is not present in node k3d-$clustername-agent-1"
|
||||||
|
|
||||||
## Container Labels
|
## Container Labels
|
||||||
info "Ensuring that container labels have been set as stated in the config"
|
info "Ensuring that container labels have been set as stated in the config"
|
||||||
@ -54,8 +54,8 @@ $EXE node list "k3d-$clustername-registry" && failed "Expected k3d-$clustername-
|
|||||||
|
|
||||||
## merged registries.yaml
|
## merged registries.yaml
|
||||||
info "Ensuring, that the registries.yaml file contains both registries"
|
info "Ensuring, that the registries.yaml file contains both registries"
|
||||||
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -i "my.company.registry" || failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
|
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -qi "my.company.registry" || failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
|
||||||
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -i "k3d-$clustername-registry" && failed "Expected 'k3d-$clustername-registry' to NOT be in the /etc/rancher/k3s/registries.yaml"
|
exec_in_node "k3d-$clustername-server-0" "cat /etc/rancher/k3s/registries.yaml" | grep -qi "k3d-$clustername-registry" && failed "Expected 'k3d-$clustername-registry' to NOT be in the /etc/rancher/k3s/registries.yaml"
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ info "Adding port-mapping to loadbalancer..."
|
|||||||
$EXE node edit k3d-$clustername-serverlb --port-add $existingPortMappingHostPort:$existingPortMappingContainerPort --port-add $newPortMappingHostPort:$newPortMappingContainerPort || failed "failed to add port-mapping to serverlb in $clustername"
|
$EXE node edit k3d-$clustername-serverlb --port-add $existingPortMappingHostPort:$existingPortMappingContainerPort --port-add $newPortMappingHostPort:$newPortMappingContainerPort || failed "failed to add port-mapping to serverlb in $clustername"
|
||||||
|
|
||||||
info "Checking port-mappings..."
|
info "Checking port-mappings..."
|
||||||
docker inspect k3d-$clustername-serverlb --format '{{ range $k, $v := .NetworkSettings.Ports }}{{ printf "%s->%s\n" $k $v }}{{ end }}' | grep -E "^$existingPortMappingContainerPort" || failed "failed to verify pre-existing port-mapping"
|
docker inspect k3d-$clustername-serverlb --format '{{ range $k, $v := .NetworkSettings.Ports }}{{ printf "%s->%s\n" $k $v }}{{ end }}' | grep -qE "^$existingPortMappingContainerPort" || failed "failed to verify pre-existing port-mapping"
|
||||||
docker inspect k3d-$clustername-serverlb --format '{{ range $k, $v := .NetworkSettings.Ports }}{{ printf "%s->%s\n" $k $v }}{{ end }}' | grep -E "^$newPortMappingContainerPort" || failed "failed to verify pre-existing port-mapping"
|
docker inspect k3d-$clustername-serverlb --format '{{ range $k, $v := .NetworkSettings.Ports }}{{ printf "%s->%s\n" $k $v }}{{ end }}' | grep -qE "^$newPortMappingContainerPort" || failed "failed to verify pre-existing port-mapping"
|
||||||
|
|
||||||
info "Checking cluster access..."
|
info "Checking cluster access..."
|
||||||
check_clusters "$clustername" || failed "error checking cluster access"
|
check_clusters "$clustername" || failed "error checking cluster access"
|
||||||
|
Loading…
Reference in New Issue
Block a user