Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] MeshSync E2E test #286

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
11aef98
Add end to end integration test
KiptoonKipkurui Dec 17, 2023
b4b98f5
rename extension
KiptoonKipkurui Dec 17, 2023
080f677
rename file
KiptoonKipkurui Dec 17, 2023
8c411c3
remove tags version
KiptoonKipkurui Dec 17, 2023
8b90376
figuring out workflow dispatch
KiptoonKipkurui Dec 17, 2023
326d83e
fix nats donwload line
KiptoonKipkurui Dec 17, 2023
2d399bf
fix folder path
KiptoonKipkurui Dec 17, 2023
37e9c30
use golang to install nats cli
KiptoonKipkurui Dec 17, 2023
3e9cb77
reorder steps
KiptoonKipkurui Dec 17, 2023
207f2e8
start nats server
KiptoonKipkurui Dec 17, 2023
3d0afbf
run meshsync in the background
KiptoonKipkurui Dec 17, 2023
97c746f
correct subscription by nats
KiptoonKipkurui Dec 17, 2023
8a19a11
export BROKER_URL to allow posting to localhost
KiptoonKipkurui Dec 17, 2023
c753dcd
added default events to all observed resources
KiptoonKipkurui Dec 17, 2023
22651dc
bolster e2e test
KiptoonKipkurui Dec 17, 2023
b281228
correct timing
KiptoonKipkurui Dec 17, 2023
5c63356
fix unit test
KiptoonKipkurui Dec 17, 2023
ba7cce8
Merge branch 'master' into feat/kiptoon/ci-tests
KiptoonKipkurui Jan 24, 2024
ead4b3a
refactor unit test
KiptoonKipkurui Jan 24, 2024
6f95b45
fix test
KiptoonKipkurui Jan 24, 2024
11f6dfa
set up meshery
KiptoonKipkurui Jan 24, 2024
95cc166
misc fixes
KiptoonKipkurui Jan 24, 2024
12b157b
misc fixes
KiptoonKipkurui Jan 24, 2024
63fcc3c
changes
KiptoonKipkurui Jan 24, 2024
abc4ef1
misc fixes
KiptoonKipkurui Jan 24, 2024
cc81104
add curl request to check resources
KiptoonKipkurui Jan 28, 2024
824b1d7
fix json path
KiptoonKipkurui Jan 28, 2024
89a5cdc
check assigning of clusters
KiptoonKipkurui Jan 28, 2024
4209f24
misc fixes
KiptoonKipkurui Jan 28, 2024
5e28a48
set provider token
KiptoonKipkurui Jan 28, 2024
0edbf3a
set provider
KiptoonKipkurui Jan 28, 2024
1d5d7ef
fix syntax error
KiptoonKipkurui Jan 28, 2024
bcd4eff
wait to ensure meshery is running
KiptoonKipkurui Jan 28, 2024
0c6909e
check meshery localhost
KiptoonKipkurui Jan 28, 2024
b624604
remove tunnelling
KiptoonKipkurui Jan 28, 2024
0fc846d
port forward service and disown
KiptoonKipkurui Jan 28, 2024
56e0b95
forward to port 8080
KiptoonKipkurui Jan 28, 2024
2cb632a
configure port forwarding
KiptoonKipkurui Jan 28, 2024
7eedd79
approach extenal ip approach
KiptoonKipkurui Jan 28, 2024
2653a5c
use load balancer ip
KiptoonKipkurui Jan 28, 2024
d9c989e
replace values
KiptoonKipkurui Jan 28, 2024
79aa737
use double quotes for string expansion
KiptoonKipkurui Jan 28, 2024
1957232
test curl
KiptoonKipkurui Jan 28, 2024
ca01ee0
try mix quoting
KiptoonKipkurui Jan 28, 2024
9990e14
better url formatting
KiptoonKipkurui Jan 28, 2024
96f50bf
add system test
KiptoonKipkurui Jan 28, 2024
7244d2c
add adapter name
KiptoonKipkurui Jan 28, 2024
f492a93
deploy meshery istio
KiptoonKipkurui Jan 28, 2024
254746c
enrich system checks
KiptoonKipkurui Jan 28, 2024
95ce8dc
remove system checks temporarily
KiptoonKipkurui Jan 28, 2024
dff4dd8
add system checks
KiptoonKipkurui Jan 28, 2024
6518c89
remove system check
KiptoonKipkurui Jan 28, 2024
ab451c5
sleep 60
KiptoonKipkurui Jan 29, 2024
50f43c1
check for deployments
KiptoonKipkurui Jan 29, 2024
692f8d2
check system logs
KiptoonKipkurui Jan 29, 2024
af54c81
check pod logs
KiptoonKipkurui Jan 29, 2024
ec29d49
configure minikube
KiptoonKipkurui Jan 29, 2024
bed69d7
install jq and pass curl output to jq
KiptoonKipkurui Jan 29, 2024
cba4acf
sleep after installing meshery
KiptoonKipkurui Jan 29, 2024
f04f00e
check for deployment
KiptoonKipkurui Jan 29, 2024
f2360b9
check for pods
KiptoonKipkurui Jan 29, 2024
6d896b4
order resutls and check for namespaces
KiptoonKipkurui Jan 29, 2024
43c2c6d
get pods
KiptoonKipkurui Jan 29, 2024
bd95b0a
include image build and image replacement
KiptoonKipkurui Jan 29, 2024
764a1ea
sleep before attempting to change image
KiptoonKipkurui Jan 29, 2024
3115327
add built image to minikube cache
KiptoonKipkurui Jan 29, 2024
65066d7
remove minikube config
KiptoonKipkurui Jan 29, 2024
90837a3
add test to ensure the pod is discovered
KiptoonKipkurui Jan 29, 2024
93b9e01
fix unit test
KiptoonKipkurui Feb 8, 2024
831aa05
more expressive error message for unit tests
KiptoonKipkurui Feb 13, 2024
fda007e
enable mesheryctl system check
KiptoonKipkurui Feb 13, 2024
442985f
remove meshery configuration
KiptoonKipkurui Feb 13, 2024
3c62262
check configuration
KiptoonKipkurui Feb 13, 2024
39e59e3
augment to run checks on preflight and operator
KiptoonKipkurui Feb 16, 2024
bd668ca
misc fixes
KiptoonKipkurui Feb 16, 2024
fe3e574
remove sleeps
KiptoonKipkurui Feb 16, 2024
4f92952
add debugging point
KiptoonKipkurui Feb 18, 2024
d374512
config minikube
KiptoonKipkurui Feb 18, 2024
6c5d1f1
silent curl
KiptoonKipkurui Feb 18, 2024
fb3e17e
reset to a workng state
KiptoonKipkurui Feb 18, 2024
6b0e017
revamped test
KiptoonKipkurui Feb 18, 2024
b8ab44d
intermediary debugging
KiptoonKipkurui Feb 19, 2024
092d89f
debug point
KiptoonKipkurui Feb 19, 2024
78cda60
debugging point
KiptoonKipkurui Feb 19, 2024
2e0a1f8
reset to a working state
KiptoonKipkurui Feb 20, 2024
f00958a
introduce looping
KiptoonKipkurui Feb 20, 2024
13ab26e
remove timing
KiptoonKipkurui Feb 20, 2024
4a0d8a5
remove timing aspect
KiptoonKipkurui Feb 20, 2024
74b71d9
debugging time sleep
KiptoonKipkurui Feb 20, 2024
b14f2ae
debugging point
KiptoonKipkurui Feb 20, 2024
44290b7
add mesheryctl system checks
KiptoonKipkurui Feb 21, 2024
5080e58
better commenting
KiptoonKipkurui Feb 22, 2024
dbe4b10
add check to ensure the needed pod
KiptoonKipkurui Feb 22, 2024
55168cf
remove sleep statements
KiptoonKipkurui Feb 22, 2024
1e59071
use successful condition
KiptoonKipkurui Feb 22, 2024
0d8f340
use roll out status
KiptoonKipkurui Feb 22, 2024
a614b9b
remove sleep
KiptoonKipkurui Feb 22, 2024
4c8a985
remove final sleep
KiptoonKipkurui Feb 22, 2024
7066b04
remove debugging info
KiptoonKipkurui Feb 22, 2024
c383a8c
wait for all pods to get to running state
KiptoonKipkurui Feb 23, 2024
98c07f5
utlize the power of kubectl
KiptoonKipkurui Feb 23, 2024
e33017b
code cleanup
KiptoonKipkurui Feb 23, 2024
d84fa1b
reduce waiting time
KiptoonKipkurui Feb 23, 2024
e41b933
add more kubernetes versions to test
KiptoonKipkurui Feb 24, 2024
f25f105
remove istio adapter
KiptoonKipkurui Feb 24, 2024
f885e96
check meshsync pod logs
KiptoonKipkurui Feb 25, 2024
36d65ad
debug info
KiptoonKipkurui Feb 25, 2024
45e9825
extract out image building to run only once
KiptoonKipkurui Feb 25, 2024
dc6d4f7
add needs field
KiptoonKipkurui Feb 25, 2024
62e88e5
upload and download images
KiptoonKipkurui Feb 25, 2024
53bd173
ensure meshsync pod is ready before deploying test pod
KiptoonKipkurui Feb 25, 2024
c184eca
debugging point for longer running processes
KiptoonKipkurui Feb 25, 2024
3fa1598
fix podname after deletion
KiptoonKipkurui Feb 25, 2024
2ee8167
correct command spelling
KiptoonKipkurui Feb 25, 2024
527c5b5
wait for pods to be ready
KiptoonKipkurui Feb 25, 2024
86491cd
remove step not needed
KiptoonKipkurui Feb 26, 2024
1fbb426
get meshery logs
KiptoonKipkurui Feb 26, 2024
862063c
log meshery for debugging purposes
KiptoonKipkurui Feb 26, 2024
8a0e5fc
remove unused line
KiptoonKipkurui Feb 26, 2024
7aece57
remove unused lines
KiptoonKipkurui Feb 26, 2024
2e99972
set up meshsy config independently
KiptoonKipkurui Feb 28, 2024
78e44ef
restore meshery configs
KiptoonKipkurui Feb 28, 2024
8cf0c58
log the broker's logs
KiptoonKipkurui Feb 28, 2024
290ccf0
use local instance of Pipelines to avoid having to rewrite the test e…
KiptoonKipkurui Feb 28, 2024
5e45525
Merge branch 'master' into feat/kiptoon/ci-tests
KiptoonKipkurui Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions .github/workflows/e2etests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: E2E tests for MeshSync

on: [push]
# push:
# branches:
# - "*"
# pull_request:
# branches:
# - "*"
jobs:
image-build:
name: Image Build Job
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
tags: meshery-meshsync:test
outputs: type=docker,dest=/tmp/meshery-meshsync.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: meshery-meshsync
path: /tmp/meshery-meshsync.tar

e2e-test:
name: End to End
runs-on: ubuntu-22.04
needs: image-build
strategy:
fail-fast: false
matrix:
k8s_version: ["v1.21.5", "v1.22.2", "v1.23.9", "v1.25.2", "v1.26.11", "v1.27.8", "v1.28.4", "v1.29.0"]

steps:
- name: Install JQ
run: |
sudo apt-get install jq
- name: Setup Kubernetes
uses: manusa/[email protected]
with:
minikube version: 'v1.30.1'
kubernetes version: ${{matrix.k8s_version}}
driver: docker

- name: Retrieve kubeconfig
run: |
echo "Before flattening"
cat ~/.kube/config
kubectl config view --minify --flatten > ~/.kube/configtemp
mv ~/.kube/configtemp ~/.kube/config
echo "After flattening"
cat ~/.kube/config
# Setup meshery config.yaml and auth.json
- name: Setup meshery config and infinite token for use
env:
provider_token: ${{ secrets.PROVIDER_TOKEN }}
provider: "Meshery"
run: |
echo $provider_token
mkdir ~/.meshery
config='{"contexts":{"local":{"endpoint":"http://localhost:9081","token":"default","platform":"kubernetes","components":[],"channel":"stable","version":"latest"}},"current-context":"local","tokens":[{"location":"auth.json","name":"default"}]}'
echo $config > ~/.meshery/config.yaml
cat ~/.meshery/config.yaml
echo "Using provider": $provider
if [ $provider = "Meshery" ] && [ "$provider_token" != "" ] ;then
echo '{ "meshery-provider": "Meshery", "token": null }' | jq -c '.token = "'$provider_token'"' > ~/.meshery/auth.json
else
echo '{ "meshery-provider": "None", "token": "" }' > ~/.meshery/auth.json
fi
cat ~/.meshery/auth.json
- name: Cluster info for debugging before starting Meshery
run: kubectl get all -A
# Start Meshery Server (Assuming that this step will create the meshery namespace)
- name: Start Meshery Server using mesheryctl
run: |
curl -L https://meshery.io/install | PLATFORM=kubernetes bash -
# wait for Meshery constituent parts to become operational
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
- name: Run minikube tunnel
run: |
echo 'Running minikube tunnel'
minikube tunnel $> /dev/null &
shell: bash

# If external IP has not been allotted then server is unreachable, exit here in that case
- name: Check if Meshery has been allotted external IP
run: |
svcstatus=$(kubectl get svc -n meshery| grep meshery | tr -s ' ' | cut -d " " -f 4)
echo $svcstatus
if [ "$svcstatus" = "<pending>" ];then
exit 1
fi
# Reset meshery's address to the external IP in config.yaml such that mesheryctl can reach it
- name: Reset Meshery address
run: |
kubectl get svc -n meshery
svcip="http://$(kubectl get svc -n meshery | grep "meshery " | tr -s ' ' | cut -d " " -f 3):9081"
echo "this is $svcip"
config='{"contexts":{"local":{"endpoint":'$svcip',"token":"default","platform":"kubernetes","adapters":["name":"meshery-istio","location":"10000"],"channel":"stable","version":"latest"}},"current-context":"local","tokens":[{"location":"auth.json","name":"default"}]}'
echo $config > ~/.meshery/config.yam
mesheryctl mesh deploy meshery-istio
- name: System Checks
run: |
mesheryctl system check --preflight
mesheryctl system check --operator
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: meshery-meshsync
path: /tmp
- name: Load MeshSync Docker image
run: |
docker load --input /tmp/meshery-meshsync.tar
docker image ls -a
minikube image load meshery-meshsync:test
# Ensure Meshery Components are running.
- name: Check Meshery Components
run: |
kubectl rollout status deployment -n meshery
- name: Replace MeshSync
run: |
# # Set your deployment name, container name, new image version, and new image pull policy
DEPLOYMENT_NAME="meshery-meshsync"
CONTAINER_NAME="meshsync"
NEW_IMAGE_VERSION="meshery-meshsync:test"
NEW_IMAGE_PULL_POLICY="IfNotPresent"
NAMESPACE="meshery"
## Update the deployment with the new image and pull policy
kubectl scale --replicas=0 deployment ${DEPLOYMENT_NAME} -n meshery
kubectl rollout status deployment ${DEPLOYMENT_NAME} -n $NAMESPACE
kubectl set image deployment/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${NEW_IMAGE_VERSION} -n $NAMESPACE
kubectl patch -n meshery deployment meshery-meshsync -p '{"spec":{"template":{"spec":{"containers":[{"name":"meshsync","imagePullPolicy":"IfNotPresent", "image":"meshery-meshsync:test"}]}}}}'
kubectl scale --replicas=1 deployment ${DEPLOYMENT_NAME} -n meshery
kubectl rollout status deployment ${DEPLOYMENT_NAME} -n $NAMESPACE
kubectl get pods -A
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
# Deploy pod
kubectl run nginx-pod --image=nginx --labels=app=web,tier=frontend,purpose=meshsync-test
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
kubectl get pods -A
mesheryctl system logs meshery
mesheryctl system logs meshsync
CLUSTER_ID=$(kubectl get ns kube-system -o jsonpath='{.metadata.uid}')
echo $CLUSTER_ID
svcip="http://$(kubectl get svc -n meshery | grep "meshery " | tr -s ' ' | cut -d " " -f 3):9081"
echo "this is $svcip"
SECONDS=0
end=$((SECONDS+300))
while [ $SECONDS -lt $end ]; do
result=$(curl -s --location "${svcip}/api/system/meshsync/resources?kind=Pod&spec=true&annotations=true&labels=true&clusterIds=%5B\"${CLUSTER_ID}\"%5D&page=0&pagesize=25&search=&order=&sort=desc" \
--header "meshery-token: ${{ secrets.PROVIDER_TOKEN }}" \
--header "Cookie: meshery-provider=Meshery; token=${{ secrets.PROVIDER_TOKEN }}" | jq '.resources[].metadata.labels[] | select(.key == "purpose" and .value == "meshsync-test")')
broker=$(kubectl get pods -n meshery | grep meshsync | tr -s ' ' | cut -d " " -f 1)
kubectl logs $broker -n $NAMESPACE
# Check if the variable is empty (no match found)
if [ -n "$result" ]; then
echo "Match found: $result"
break
fi
done
# Check if the loop completed its iterations without finding a match
if [ -z "$result" ]; then
echo "Error: MeshSync unable to discover resources."
exit 1
fi
shell: bash
111 changes: 108 additions & 3 deletions internal/config/crd_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,112 @@ var (
)

func TestWhiteListResources(t *testing.T) {

Pipelines = map[string]PipelineConfigs{
GlobalResourceKey: []PipelineConfig{
// Core Resources
{
Name: "namespaces.v1.",
PublishTo: DefaultPublishingSubject,
},
{
Name: "configmaps.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "nodes.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "secrets.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "persistentvolumes.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "persistentvolumeclaims.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
},
LocalResourceKey: []PipelineConfig{
// Core Resources
{
Name: "replicasets.v1.apps",
PublishTo: DefaultPublishingSubject,
},
{
Name: "pods.v1.",
PublishTo: DefaultPublishingSubject,
},
{
Name: "services.v1.",
PublishTo: DefaultPublishingSubject,
},
{
Name: "deployments.v1.apps",
PublishTo: DefaultPublishingSubject,
},
{
Name: "statefulsets.v1.apps",
PublishTo: DefaultPublishingSubject,
},
{
Name: "daemonsets.v1.apps",
PublishTo: DefaultPublishingSubject,
},
//Added Ingress support
{
Name: "ingresses.v1.networking.k8s.io",
PublishTo: DefaultPublishingSubject,
},
// Added endpoint support
{
Name: "endpoints.v1.",
PublishTo: DefaultPublishingSubject,
},
//Added endpointslice support
{
Name: "endpointslices.v1.discovery.k8s.io",
PublishTo: DefaultPublishingSubject,
},
// Added cronJob support
{
Name: "cronjobs.v1.batch",
PublishTo: DefaultPublishingSubject,
},
//Added ReplicationController support
{
Name: "replicationcontrollers.v1.",
PublishTo: DefaultPublishingSubject,
},
//Added storageClass support
{
Name: "storageclasses.v1.storage.k8s.io",
PublishTo: DefaultPublishingSubject,
},
//Added ClusterRole support
{
Name: "clusterroles.v1.rbac.authorization.k8s.io",
PublishTo: DefaultPublishingSubject,
},
//Added VolumeAttachment support
{
Name: "volumeattachments.v1.storage.k8s.io",
PublishTo: DefaultPublishingSubject,
},
//Added apiservice support
{
Name: "apiservices.v1.apiregistration.k8s.io",
PublishTo: DefaultPublishingSubject,
},
},
}
// Create an instance of the custom resource.
watchList := corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -107,10 +212,10 @@ func TestBlackListResources(t *testing.T) {
// excempted local pipelines: pods, replicasets

if len(meshsyncConfig.Pipelines["global"]) != 5 {
t.Error("global pipelines not well configured expected 5")
t.Errorf("global pipelines not well configured got %d expected 6", len(meshsyncConfig.Pipelines["global"]))
}

if len(meshsyncConfig.Pipelines["local"]) != 14 {
t.Error("global pipelines not well configured expected 15")
t.Errorf("global pipelines not well configured got %d expected 15", len(meshsyncConfig.Pipelines["local"]))
}
}
7 changes: 6 additions & 1 deletion internal/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,27 @@ var (
{
Name: "configmaps.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "nodes.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "secrets.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "persistentvolumes.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
{
Name: "persistentvolumeclaims.v1.",
PublishTo: "meshery.meshsync.core",
Events: DefaultEvents,
},
},
LocalResourceKey: []PipelineConfig{
Expand Down Expand Up @@ -134,5 +139,5 @@ var (
},
}

DefaultEvents = []string{"ADD", "UPDATE", "DELETE"}
DefaultEvents = []string{"ADDED", "MODIFIED", "DELETED"}
)
Loading