Skip to content

Commit a1b2eec

Browse files
committed
AOTC component tests
1 parent 02b0ce7 commit a1b2eec

File tree

14 files changed

+2406
-4
lines changed

14 files changed

+2406
-4
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Component Tests
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
env:
13+
# Test environment configuration
14+
HARBOR_SERVER: https://harbor.kind.internal
15+
HARBOR_NAMESPACE: harbor
16+
HARBOR_ADMIN_CREDENTIAL: admin-secret
17+
KEYCLOAK_SERVER: https://keycloak.kind.internal
18+
KEYCLOAK_NAMESPACE: keycloak
19+
KEYCLOAK_SECRET: keycloak-secret
20+
VAULT_SERVER: https://vault.kind.internal
21+
CATALOG_SERVER: https://catalog.kind.internal
22+
ADM_SERVER: https://adm.kind.internal
23+
RS_ROOT_URL: oci://registry.kind.internal
24+
RS_PROXY_ROOT_URL: https://registry.kind.internal
25+
MANIFEST_PATH: /manifests
26+
MANIFEST_TAG: latest
27+
REGISTRY_HOST_EXTERNAL: https://harbor.kind.internal
28+
SERVICE_ACCOUNT: default
29+
30+
jobs:
31+
component-tests:
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 45
34+
35+
strategy:
36+
matrix:
37+
go-version: ['1.21', '1.22']
38+
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Go ${{ matrix.go-version }}
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version: ${{ matrix.go-version }}
47+
48+
- name: Cache Go modules
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
~/.cache/go-build
53+
~/go/pkg/mod
54+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
55+
restore-keys: |
56+
${{ runner.os }}-go-${{ matrix.go-version }}-
57+
58+
- name: Create KinD cluster
59+
uses: helm/[email protected]
60+
with:
61+
cluster_name: kind
62+
config: .github/workflows/kind-config.yaml
63+
64+
- name: Install kubectl
65+
uses: azure/setup-kubectl@v4
66+
with:
67+
version: 'v1.29.0'
68+
69+
- name: Install Helm
70+
uses: azure/setup-helm@v4
71+
with:
72+
version: '3.13.0'
73+
74+
- name: Set up test infrastructure
75+
run: |
76+
# Install required CRDs and services for testing
77+
kubectl create namespace harbor --dry-run=client -o yaml | kubectl apply -f -
78+
kubectl create namespace keycloak --dry-run=client -o yaml | kubectl apply -f -
79+
kubectl create namespace orch-app --dry-run=client -o yaml | kubectl apply -f -
80+
81+
# Create mock services for testing
82+
kubectl apply -f .github/workflows/test-services.yaml
83+
84+
- name: Wait for test infrastructure
85+
run: |
86+
# Wait for mock services to be ready
87+
kubectl wait --for=condition=available --timeout=300s deployment/mock-harbor -n harbor
88+
kubectl wait --for=condition=available --timeout=300s deployment/mock-keycloak -n keycloak
89+
kubectl wait --for=condition=available --timeout=300s deployment/mock-catalog -n orch-app
90+
91+
- name: Set up port forwarding
92+
run: |
93+
# Set up port forwarding for test services
94+
kubectl port-forward -n harbor svc/mock-harbor 8080:80 &
95+
kubectl port-forward -n keycloak svc/mock-keycloak 8081:80 &
96+
kubectl port-forward -n orch-app svc/mock-catalog 8082:80 &
97+
sleep 10 # Give port forwarding time to establish
98+
99+
- name: Download dependencies
100+
run: |
101+
go mod download
102+
go mod vendor
103+
104+
- name: Build application
105+
run: |
106+
make go-build
107+
108+
- name: Run unit tests
109+
run: |
110+
make go-test
111+
112+
- name: Run component tests
113+
run: |
114+
make component-test
115+
116+
- name: Run component tests with coverage
117+
run: |
118+
make component-test-coverage
119+
120+
- name: Upload coverage reports
121+
uses: codecov/codecov-action@v4
122+
with:
123+
files: ./coverage.xml,./component-coverage.xml
124+
flags: component-tests
125+
name: component-coverage
126+
fail_ci_if_error: false
127+
128+
- name: Archive test results
129+
uses: actions/upload-artifact@v4
130+
if: always()
131+
with:
132+
name: component-test-results-go${{ matrix.go-version }}
133+
path: |
134+
coverage.xml
135+
component-coverage.xml
136+
*.log
137+
138+
- name: Cleanup
139+
if: always()
140+
run: |
141+
# Kill port forwarding processes
142+
pkill -f "kubectl port-forward" || true
143+
# Additional cleanup if needed
144+
kubectl delete namespace harbor keycloak orch-app --ignore-not-found=true

.github/workflows/kind-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# KinD cluster configuration for component tests
5+
kind: Cluster
6+
apiVersion: kind.x-k8s.io/v1alpha4
7+
name: kind
8+
9+
# Configure the cluster for testing
10+
nodes:
11+
- role: control-plane
12+
kubeadmConfigPatches:
13+
- |
14+
kind: InitConfiguration
15+
nodeRegistration:
16+
kubeletExtraArgs:
17+
node-labels: "ingress-ready=true"
18+
extraPortMappings:
19+
# Use different ports to avoid conflicts with existing services
20+
- containerPort: 30080
21+
hostPort: 8080
22+
protocol: TCP
23+
- containerPort: 30081
24+
hostPort: 8081
25+
protocol: TCP
26+
- containerPort: 30082
27+
hostPort: 8082
28+
protocol: TCP
29+
30+
# Configure networking
31+
networking:
32+
apiServerAddress: "127.0.0.1"
33+
apiServerPort: 6443
34+
podSubnet: "10.244.0.0/16"
35+
serviceSubnet: "10.96.0.0/16"

0 commit comments

Comments
 (0)