Skip to content

Commit cdb516c

Browse files
committed
feat: add Kubernetes-based e2e testing infrastructure
This commit adds comprehensive Kubernetes-based end-to-end testing support for ORAS. GitHub Actions workflow for automated KinD-based testing This maintains compatibility with existing Docker-based e2e tests while adding a more realistic Kubernetes-based testing environment. Signed-off-by: Terry Howe <terrylhowe@gmail.com>
1 parent 7ab61a4 commit cdb516c

26 files changed

+2003
-412
lines changed

.github/workflows/e2e-k8s.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright The ORAS Authors.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
name: e2e-k8s
15+
16+
on:
17+
push:
18+
branches:
19+
- main
20+
- release-*
21+
pull_request:
22+
branches:
23+
- main
24+
- release-*
25+
26+
jobs:
27+
e2e-k8s:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
go-version: ['1.25']
32+
fail-fast: true
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v5
36+
37+
- name: Setup Go ${{ matrix.go-version }}
38+
uses: actions/setup-go@v6
39+
with:
40+
go-version: ${{ matrix.go-version }}
41+
check-latest: true
42+
43+
- name: Create k8s KinD Cluster
44+
uses: helm/kind-action@v1
45+
with:
46+
cluster_name: kind
47+
48+
- name: Verify Cluster
49+
run: |
50+
kubectl cluster-info
51+
kubectl get nodes
52+
53+
- name: Build Test Image
54+
run: |
55+
cd test/e2e/scripts
56+
./build-image.sh
57+
58+
- name: Deploy Test Registries
59+
run: |
60+
cd test/e2e/scripts
61+
./deploy.sh
62+
63+
- name: Wait for Registries
64+
run: |
65+
cd test/e2e/scripts
66+
./status.sh
67+
68+
- name: Run E2E Tests
69+
run: |
70+
cd test/e2e/scripts
71+
./run-tests.sh
72+
env:
73+
ORAS_PATH: /workspace/bin/linux/amd64/oras
74+
75+
- name: Show Registry Logs on Failure
76+
if: failure()
77+
run: |
78+
echo "=== Docker Registry Logs ==="
79+
kubectl logs -n oras-e2e-tests deployment/docker-registry --tail=100 || true
80+
echo "=== Fallback Registry Logs ==="
81+
kubectl logs -n oras-e2e-tests deployment/fallback-registry --tail=100 || true
82+
echo "=== Zot Registry Logs ==="
83+
kubectl logs -n oras-e2e-tests deployment/zot-registry --tail=100 || true
84+
echo "=== Test Job Logs ==="
85+
kubectl logs -n oras-e2e-tests job/oras-e2e-tests --tail=200 || true
86+
87+
- name: Cleanup
88+
if: always()
89+
run: |
90+
cd test/e2e/scripts
91+
./teardown.sh || true

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,4 @@ test/e2e/testdata/distribution/mount/docker/
5252
test/e2e/testdata/distribution/mount_fallback/docker/
5353

5454

55-
# OCI Layout Files ZOT storage files for local E2E testing
56-
test/e2e/testdata/zot/
57-
!test/e2e/testdata/zot/command/images/**/*
58-
!test/e2e/testdata/zot/command/artifacts/**/*
59-
!test/e2e/testdata/zot/command/blobs/**/*
60-
!test/e2e/testdata/zot/config.json
61-
!test/e2e/testdata/zot/passwd_bcrypt
62-
6355
test/e2e/go.work.sum

test/e2e/Dockerfile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Copyright The ORAS Authors.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# Build stage
15+
FROM golang:1.25-alpine AS builder
16+
17+
# Install build dependencies
18+
RUN apk add --no-cache git make
19+
20+
# Set working directory
21+
WORKDIR /workspace
22+
23+
# Copy go mod files first for better caching
24+
COPY go.mod go.sum ./
25+
RUN go mod download
26+
RUN go mod vendor
27+
28+
# Copy the entire source code
29+
COPY . .
30+
31+
# Run stage
32+
FROM golang:1.25-alpine
33+
34+
# Install runtime dependencies including build tools for CGO (required for -race flag)
35+
RUN apk add --no-cache ca-certificates git curl wget bash gcc musl-dev make file
36+
37+
# Set working directory
38+
WORKDIR /workspace
39+
40+
# Copy from builder
41+
COPY --from=builder /go/pkg /go/pkg
42+
COPY --from=builder /workspace /workspace
43+
44+
# Ensure module cache is properly set up
45+
RUN go mod download
46+
RUN go mod vendor
47+
48+
# Install ginkgo test runner
49+
RUN cd test/e2e && go install github.com/onsi/ginkgo/v2/ginkgo@latest
50+
ENV PATH="${PATH}:/go/bin"
51+
52+
# Set plain HTTP mode for tests (registries in k8s use HTTP not HTTPS)
53+
ENV ORAS_E2E_PLAIN_HTTP="true"
54+
55+
# Create entrypoint script that builds oras and runs tests
56+
RUN cat > /entrypoint.sh <<'EOF'
57+
#!/bin/sh
58+
set -e
59+
60+
echo "==================================="
61+
echo "ORAS E2E Test Environment Setup"
62+
echo "==================================="
63+
echo ""
64+
echo "Building oras binary..."
65+
66+
cd /workspace
67+
68+
# Build oras using make (determines correct OS and ARCH automatically)
69+
make > out || cat out
70+
71+
# Construct the binary path using Makefile logic: bin/$(OS)/$(ARCH)/$(CLI_EXE)
72+
ORAS_BIN="/workspace/bin/linux/amd64/oras"
73+
74+
if [ ! -f "$ORAS_BIN" ]; then
75+
echo "Error: oras binary not found at expected path: $ORAS_BIN"
76+
echo "Available binaries:"
77+
find /workspace/bin -name oras -type f 2>/dev/null || echo " None found"
78+
exit 1
79+
fi
80+
81+
echo "✓ Built oras binary: $ORAS_BIN"
82+
echo ""
83+
84+
# Export ORAS_PATH for tests to use
85+
export ORAS_PATH="$ORAS_BIN"
86+
87+
# Change to test directory
88+
cd /workspace/test/e2e
89+
90+
# Run provided command or default to ginkgo tests
91+
if [ $# -eq 0 ]; then
92+
echo "Running ginkgo tests..."
93+
echo "-----------------------------------"
94+
exec ginkgo -r -p --race suite
95+
else
96+
# Execute the provided command with ORAS_PATH set
97+
exec "$@"
98+
fi
99+
EOF
100+
101+
RUN chmod +x /entrypoint.sh
102+
103+
# Set working directory
104+
WORKDIR /workspace/test/e2e
105+
106+
# Use the entrypoint script
107+
ENTRYPOINT ["/entrypoint.sh"]
108+
CMD []

0 commit comments

Comments
 (0)