diff --git a/e2e/test/route-controller-test/chainsaw-test.yaml b/e2e/test/route-controller-test/chainsaw-test.yaml new file mode 100644 index 00000000..236f13df --- /dev/null +++ b/e2e/test/route-controller-test/chainsaw-test.yaml @@ -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