-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testing] E2E test case for VPC route controller (#280)
* Add the chainsaw test * Address comment
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: route-controller-test | ||
spec: | ||
bindings: | ||
- name: fwname | ||
value: (join('-', ['ccm-fwtest', env('CLUSTER_NAME')])) | ||
namespace: "route-controller-test" | ||
steps: | ||
- name: Check if CCM is deployed | ||
try: | ||
- assert: | ||
file: ../assert-ccm-resources.yaml | ||
- name: Check if the route controller updated the config for the linode | ||
try: | ||
- script: | ||
content: | | ||
set -e | ||
if [ -z "$KUBECONFIG" ] || [ -z "$LINODE_TOKEN" ]; then | ||
echo "Error: KUBECONFIG and LINODE_TOKEN environment variables must be set" | ||
exit 1 | ||
fi | ||
# Get all node names | ||
nodes=$(kubectl get nodes -o jsonpath='{.items[*].metadata.name}') | ||
if [ -z "$nodes" ]; then | ||
echo "Error: No nodes found in cluster" | ||
exit 1 | ||
fi | ||
# Process each node | ||
for node in $nodes; do | ||
echo "Checking node: $node" | ||
# Get pod CIDR and instance ID | ||
pod_cidr=$(kubectl get node "$node" -o jsonpath='{.spec.podCIDR}') | ||
instance_id=$(kubectl get node "$node" -o jsonpath='{.spec.providerID}' | sed 's/linode:\/\///') | ||
echo " Pod CIDR: $pod_cidr" | ||
echo " Instance ID: $instance_id" | ||
# Get interface details for this config | ||
interfaces=$(curl -s \ | ||
-H "Authorization: Bearer $LINODE_TOKEN" \ | ||
"https://api.linode.com/v4/linode/instances/$instance_id/configs" \ | ||
| jq -r '.data[0].interfaces') | ||
# Check if pod CIDR is in the VPC interface IP ranges | ||
if echo "$interfaces" | jq -e --arg cidr "$pod_cidr" '.[] | select(.purpose == "vpc") | .ip_ranges[] | select(. == $cidr)' > /dev/null; then | ||
echo "Pod CIDR found in VPC interface configuration" | ||
else | ||
echo "Pod CIDR not found in VPC interface configuration" | ||
echo "Current VPC interface configuration:" | ||
echo "$interfaces" | jq '.[] | select(.purpose == "vpc")' | ||
fi | ||
echo "---" | ||
done | ||
check: | ||
($error == null): true | ||
(contains($stdout, 'Pod CIDR not found in VPC interface configuration')): false |