Skip to content

Commit

Permalink
fix script and move e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-medvedev-codefresh committed Jun 27, 2024
1 parent ed3befc commit 0e7a78a
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .e2e/chainsaw-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@ spec:
- my-virtual-namespace
matchLabels:
vcluster.loft.sh/label-vcluster-x-a172cedcae: example-app
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: pm-with-ns-selector
spec:
steps:
- try:
- assert:
resource:
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: pm-with-ns-selector-x-default-x-vcluster
namespace: default
spec:
namespaceSelector: {}
selector:
matchExpressions:
- key: vcluster.loft.sh/namespace
operator: In
values:
- my-virtual-namespace
matchLabels:
vcluster.loft.sh/label-vcluster-x-a172cedcae: example-app
16 changes: 16 additions & 0 deletions .e2e/vcluster-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ spec:
app: example-app
endpoints:
- port: web
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: pm-with-ns-selector
namespace: default
labels:
team: frontend
spec:
namespaceSelector:
any: false
matchNames:
- my-virtual-namespace
selector:
matchLabels:
app: example-app
2 changes: 1 addition & 1 deletion v1/.e2e/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ while [ $res -ne 0 ] && [ $secondsWaited -lt $timeout ]; do
echo "Waiting for CRDs to get created, sleep for 30 seconds..."
sleep 30
secondsWaited=$((secondsWaited + 30))
vcluster connect vcluster -n default -- kubectl get servicemonitorr && vcluster connect vcluster -n default -- kubectl get podmonitor
vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor
res=$?
done

Expand Down
32 changes: 32 additions & 0 deletions v2/.e2e/scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Deploy CRDs and vcluster with the plugin, connect to vcluster and apply resources in resources folder for testing

PLUGIN_IMAGE=$1
MYDIR=$(dirname $0)
ROOT_DIR=$MYDIR/../../
RESOURCES_FILE=$MYDIR/../../../.e2e/vcluster-resources.yaml

kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml
helm upgrade --install --repo https://charts.loft.sh vcluster vcluster --version v0.20.0-beta.5 --values $MYDIR/vcluster-values.yaml --values $ROOT_DIR/plugin.yaml --set plugins.prometheus-operator-resources.image=$PLUGIN_IMAGE --wait

vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor

res=$?
secondsWaited=0
timeout=300

while [ $res -ne 0 ] && [ $secondsWaited -lt $timeout ]; do
echo "Waiting for CRDs to get created, sleep for 30 seconds..."
sleep 30
secondsWaited=$((secondsWaited + 30))
vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor
res=$?
done

if [ $res -ne 0 ]; then
echo "Timed out waiting for CRDs to get created in vcluster"
exit 1
fi

cat $RESOURCES_FILE | vcluster connect vcluster -n default -- kubectl -n default apply -f -
17 changes: 17 additions & 0 deletions v2/.e2e/scripts/vcluster-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
controlPlane:
advanced:
serviceAccount:
enabled: false
name: default
statefulSet:
probes:
livenessProbe:
enabled: false
readinessProbe:
enabled: false
distro:
k3s:
enabled: true
rbac:
clusterRole:
enabled: true
4 changes: 0 additions & 4 deletions v2/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ deployments:
repo: https://charts.loft.sh
version: v0.20.0-beta.5
values:
experimental:
syncSettings:
syncLabels:
- app
controlPlane:
advanced:
serviceAccount:
Expand Down

0 comments on commit 0e7a78a

Please sign in to comment.