-
Notifications
You must be signed in to change notification settings - Fork 252
120 lines (111 loc) · 4.68 KB
/
integration-tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Run integration tests
# Any change in triggers needs to be reflected in the concurrency group.
on:
push:
branches:
- main
- v*
pull_request:
branches:
- main
- v*
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
env:
# renovate: datasource=github-releases depName=helm/helm
HELM_VERSION: v3.16.1
# renovate: datasource=github-releases depName=kubernetes-sigs/kind
KIND_VERSION: v0.24.0
KIND_CONFIG: .github/kind-config.yaml
# renovate: datasource=github-releases depName=cilium/cilium
CILIUM_VERSION: v1.16.1
CILIUM_VALUES: .github/cilium-values.yaml
jobs:
integration-test:
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- name: Checkout the repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: 'go.mod'
- name: Build hubble CLI
run: make
- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # renovate: tag=v3.5
with:
version: ${{ env.HELM_VERSION }}
- name: Create kind cluster
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
version: ${{ env.KIND_VERSION }}
config: ${{ env.KIND_CONFIG }}
cluster_name: kind
- name: Deploy Cilium
run: |
# Deploy cilium with KPR
MASTER_IP="$(docker inspect kind-control-plane | jq '.[0].NetworkSettings.Networks.kind.IPAddress' -r)"
helm repo add cilium https://helm.cilium.io
helm repo update
helm install cilium cilium/cilium \
--wait \
--namespace kube-system \
--version ${{ env.CILIUM_VERSION }} \
--values ${{ env.CILIUM_VALUES }} \
--set kubeProxyReplacement=true \
--set k8sServiceHost="${MASTER_IP}" \
--set k8sServicePort=6443
- name: Wait for hubble-relay to be running
run: |
kubectl -n kube-system rollout status deployment/hubble-relay
- name: Run integration tests
timeout-minutes: 5
# work around for hubble CLI thinking we're piping something in via
# stdin, even though we aren't
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
set -ex
./hubble --version
kubectl -n kube-system port-forward service/hubble-relay 4245:80 &
# wait until the port-forward is running
until [ $(pgrep --count --full "kubectl.*port-forward.*service\/hubble-relay.*4245:80") -eq 1 ]; do
sleep 1
done
# give relay a little bit more time to actually connect to agent before running commands.
sleep 5
./hubble status
# query hubble until we receive flows, or timeout
flowCount=0
until [ $flowCount -gt 0 ]; do
./hubble observe -n kube-system -o jsonpb | tee flows.json
flowCount=$(jq -r --slurp 'length' flows.json)
sleep 5
done
# verify we got some flows
test $(jq -r --slurp 'length' flows.json) -gt 0
# test piping flows into the CLI
test $(./hubble observe < flows.json -o json | jq -r --slurp 'length') -eq $(jq -r --slurp 'length' flows.json)
- name: Post-test information gathering
if: ${{ !success() }}
run: |
echo "Gathering information about KIND cluster"
function get_logs() {
CMD=(kubectl logs --timestamps --since 30m $@)
"${CMD[@]}" || "${CMD[@]}" -p || echo "Unable to get logs for $@"
}
echo "==================== CURRENT TIME ===================="
date -u
echo "==================== ALL NODES ===================="
kubectl get nodes --output wide --show-labels
echo "==================== ALL PODS ===================="
kubectl get pods --all-namespaces --output wide
echo "==================== CILIUM AGENT LOGS ===================="
get_logs -l "k8s-app=cilium" -n kube-system -c cilium-agent
echo "==================== HUBBLE RELAY LOGS ===================="
get_logs -l "k8s-app=hubble-relay" -n kube-system -c hubble-relay
echo "==================== CILIUM STATUS ===================="
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium status --verbose
shell: bash {0} # Disable default fail-fast behaviour so that all commands run independently