Commit c2f22c3
test: add AgentJoinKubernetes and AgentHelmInstall e2e test cases (#121)
* test: add AgentJoinKubernetes and AgentHelmInstall e2e test cases
Add two new e2e test cases for kubernetes-type agent deployment flows:
- AgentJoinKubernetes: runs 'kedge agent join --type kubernetes' as a
one-shot install command that deploys the agent as a Kubernetes
Deployment in kedge-system, then verifies the Deployment becomes
available and the hub edge reaches Ready.
- AgentHelmInstall: installs the agent via the local kedge-agent Helm
chart using 'helm install --wait', then verifies the hub edge reaches
Ready. Cleanup uses 'helm uninstall'.
Add WaitForDeploymentAvailable to test/e2e/framework/client.go to poll
kubectl until availableReplicas >= 1 or timeout.
Both tests skip gracefully when no agent kubeconfig is available and
clean up best-effort on teardown.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
* fix: use Docker network IP for in-cluster hub URL in e2e tests
- Add HubNodePortURL() helper to framework/cluster.go that resolves the
hub's Docker network IP and returns https://<ip>:31443, which is
reachable from pods inside the agent kind cluster.
- Update AgentJoinKubernetes and AgentHelmInstall to call HubNodePortURL()
instead of clusterEnv.HubURL (kedge.localhost does not resolve inside pods).
Tests are skipped when the Docker IP cannot be determined.
- Add --set agent.hub.insecureSkipTLSVerify=true to the helm install in
AgentHelmInstall so the agent pod trusts the self-signed hub certificate.
- Fix Helm chart deployment.yaml: change --hub-insecure-skip-tls-verify to
--insecure-skip-tls-verify, which is the actual flag name accepted by the
kedge-agent binary.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
* fix: correct Docker network IP resolution and add diagnostics in e2e tests
- Fix HubNodePortURL() to use specific kind network name (kedge-e2e) instead
of ranging over all networks — avoids concatenated IPs (e.g. 172.18.0.2172.17.0.2)
when the hub node is connected to multiple Docker networks.
Format: {{(index .NetworkSettings.Networks "kedge-e2e").IPAddress}}
- Add t.Logf("using pod hub URL: %s") in both AgentJoinKubernetes and
AgentHelmInstall setup functions so the resolved URL is visible in CI logs.
- Add pod-log and pod-describe diagnostics in both edge_becomes_ready assess
steps, collected before t.Fatalf so timeout failures include agent logs.
- Fix Helm chart deployment.yaml: --hub-insecure-skip-tls-verify ->
--insecure-skip-tls-verify (actual flag name accepted by kedge-agent binary).
- Add --set agent.hub.insecureSkipTLSVerify=true to AgentHelmInstall helm
install so the in-cluster agent pod trusts the self-signed hub certificate.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
* fix: use PodHubURL to preserve cluster name path in agent pod tests
The AgentJoinKubernetes and AgentHelmInstall tests were failing with
'websocket: bad handshake' because the agent pod connected to:
wss://172.18.0.2:31443/services/agent-proxy/default/...
The cluster name segment 'default' came from calling HubNodePortURL()
which returns a bare 'https://172.18.0.2:31443' URL with no path.
SplitBaseAndCluster falls back to 'default' when no /clusters/<name>
path is present.
Add PodHubURL(clusterHubURL string) to the test framework. It keeps
the /clusters/<name> path from the runner-side URL (clusterEnv.HubURL)
while substituting the host:port with the Docker-network NodePort
address reachable from inside the agent pods.
Replace both framework.HubNodePortURL() call sites in join_token.go
with framework.PodHubURL(clusterEnv.HubURL) so SplitBaseAndCluster
correctly extracts 'root:kedge:user-default' instead of 'default'.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: mjudeikis-bot <ai@faros.sh>
* feat: make kedge-agent image configurable via env vars for e2e
The kedge-agent container image used in AgentJoinKubernetes and
AgentHelmInstall e2e tests was hard-coded to ghcr.io/faroshq/kedge-agent:latest
which required a network pull in CI and could use a stale image.
Changes:
- pkg/cli/cmd/install.go: read KEDGE_AGENT_IMAGE, KEDGE_AGENT_IMAGE_TAG,
KEDGE_AGENT_IMAGE_PULL_POLICY env vars in installKubernetes; update
agentManifestTemplate to use {{.Image}}:{{.ImageTag}} and {{.ImagePullPolicy}}
- pkg/cli/cmd/agent.go: same env vars in agentJoinKubernetes; add
imagePullPolicy field to both token-based and kubeconfig-based Deployment
manifests
- test/e2e/framework/cluster.go: add agentImageEnv, agentImageTagEnv,
agentImagePullPolicyEnv constants; add LoadAgentImageIntoCluster helper
that runs 'kind load docker-image' when KEDGE_AGENT_IMAGE_PULL_POLICY=Never
- test/e2e/cases/join_token.go: call LoadAgentImageIntoCluster in
AgentJoinKubernetes and AgentHelmInstall setup; pass image overrides to
helm install via --set flags
- .github/workflows/e2e.yaml: build agent Docker image in e2e-standalone job;
set KEDGE_AGENT_IMAGE/TAG/PULL_POLICY=Never env vars on the e2e run step
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: mjudeikis-bot <ai@faros.sh>
* test: replace PodHubURL with PodHubURLFromKubeconfig for correct cluster path
PodHubURL(clusterEnv.HubURL) was still broken because clusterEnv.HubURL
is ALWAYS "https://kedge.localhost:8443" (no /clusters/<name> path).
Substituting the host in that bare URL still produces a URL without a
cluster path, causing SplitBaseAndCluster to fall back to "default".
The cluster path lives in the hub kubeconfig server URL, e.g.:
https://kedge.localhost:8443/clusters/root:kedge:user-default
Replace PodHubURL(clusterHubURL string) with
PodHubURLFromKubeconfig(kubeconfigPath string) which:
1. Calls HubNodePortURL() to get the Docker-network NodePort address.
2. Reads cfg.Host from the hub kubeconfig (contains the full cluster path).
3. Replaces scheme+host with the NodePort address while preserving the
/clusters/... path segment.
Update AgentJoinKubernetes and AgentHelmInstall to call
PodHubURLFromKubeconfig(clusterEnv.HubKubeconfig) so the --hub-url
flag passed to in-cluster agents includes the correct cluster path.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: mjudeikis-bot <ai@faros.sh>
* fix: always mark edge Ready on tunnel open regardless of auth method
When an in-cluster agent restarts and reconnects using its saved kubeconfig
(loaded from a Secret after the join-token exchange), the hub was not marking
the edge as Ready/Connected because markEdgeConnected was gated on
authenticatedByJoinToken.
The agent's edge_reporter (which was supposed to handle this for kubeconfig
connections) also failed with 'access denied' due to RBAC propagation timing.
Fix: call markEdgeConnected on every tunnel open. The hub is authoritative
for edge connectivity state regardless of how the agent authenticated. This
is safe because the join token is only cleared when it was set, and SSH
credentials are extracted from headers in both paths.
Fixes the AgentJoinKubernetes and AgentHelmInstall e2e tests.
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: mjudeikis-bot <ai@faros.sh>
---------
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Signed-off-by: mjudeikis-bot <ai@faros.sh>
Co-authored-by: mjudeikis-bot <mjudeikis-bot@faros.sh>
Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
Co-authored-by: mjudeikis-bot <ai@faros.sh>1 parent fb1ca2e commit c2f22c3
9 files changed
Lines changed: 444 additions & 15 deletions
File tree
- .github/workflows
- deploy/charts/kedge-agent/templates
- pkg
- cli/cmd
- virtual/builder
- test/e2e
- cases
- framework
- suites/standalone
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
| |||
348 | 360 | | |
349 | 361 | | |
350 | 362 | | |
| 363 | + | |
351 | 364 | | |
352 | 365 | | |
353 | 366 | | |
354 | | - | |
| 367 | + | |
355 | 368 | | |
356 | 369 | | |
357 | 370 | | |
| |||
409 | 422 | | |
410 | 423 | | |
411 | 424 | | |
| 425 | + | |
412 | 426 | | |
413 | 427 | | |
414 | 428 | | |
| |||
420 | 434 | | |
421 | 435 | | |
422 | 436 | | |
423 | | - | |
| 437 | + | |
424 | 438 | | |
425 | 439 | | |
426 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
282 | 296 | | |
283 | 297 | | |
284 | | - | |
285 | | - | |
286 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
287 | 304 | | |
288 | 305 | | |
289 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
167 | 172 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
0 commit comments