Skip to content

Commit

Permalink
add clusterpolicy custom labels e2e test scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
tariq1890 committed Jan 11, 2023
1 parent a438e00 commit bb07d0a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/scripts/update-clusterpolicy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,39 @@ test_custom_toolkit_dir() {
check_pod_ready "nvidia-operator-validator"
}

test_custom_labels_override() {
if ! kubectl patch clusterpolicy/cluster-policy --type='json' -p='[{"op": "add", "path": "/spec/daemonsets/labels", "value": {"cloudprovider": "aws", "platform": "kubernetes"}}]';
then
echo "cannot update the labels of the ClusterPolicy resource"
exit 1
fi

operands="nvidia-container-toolkit-daemonset nvidia-operator-validator gpu-feature-discovery nvidia-dcgm-exporter nvidia-device-plugin-daemonset"

for operand in $operands
do
check_pod_ready "$operand"
done

for operand in $operands
do
echo "checking $operand labels"
for pod in $(kubectl get pods -n "$TEST_NAMESPACE" -l app="$operand" --output=jsonpath={.items..metadata.name})
do
cp_label_value=$(kubectl get pod -n "$TEST_NAMESPACE" "$pod" --output jsonpath={.metadata.labels.cloudprovider})
if [ "$cp_label_value" != "aws" ]; then
echo "Custom Label cloudprovider is incorrect when clusterpolicy labels are overridden - $pod"
exit 1
fi
platform_label_value=$(kubectl get pod -n "$TEST_NAMESPACE" "$pod" --output jsonpath={.metadata.labels.platform})
if [ "$platform_label_value" != "kubernetes" ]; then
echo "Custom Label platform is incorrect when clusterpolicy labels are overridden - $pod"
exit 1
fi
done
done
}


test_image_updates
test_env_updates
Expand All @@ -212,3 +245,4 @@ test_enable_dcgm
test_gpu_sharing
test_disable_enable_gfd
test_disable_enable_dcgm_exporter
test_custom_labels_override

0 comments on commit bb07d0a

Please sign in to comment.