Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
111 changes: 111 additions & 0 deletions .github/workflows/apisix-conformance-test.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: APISIX Conformance Test

on:
push:
branches:
- master
- release-v2-dev
pull_request:
branches:
- master
- release-v2-dev

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
prepare:
name: Prepare
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go Env
id: go
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Install kind
run: |
go install sigs.k8s.io/[email protected]

conformance-test:
timeout-minutes: 60
needs:
- prepare
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Build images
env:
TAG: dev
ARCH: amd64
ENABLE_PROXY: "false"
BASE_IMAGE_TAG: "debug"
run: |
echo "building images..."
make build-image

- name: Launch Kind Cluster
run: |
make kind-up

- name: Install And Run Cloud Provider KIND
run: |
go install sigs.k8s.io/cloud-provider-kind@latest
nohup cloud-provider-kind > /tmp/kind-loadbalancer.log 2>&1 &

- name: Install Gateway API And CRDs
run: |
make install

- name: Loading Docker Image to Kind Cluster
run: |
make kind-load-images

- name: Run Conformance Test
shell: bash
continue-on-error: true
run: |
make conformance-test-standalone

- name: Get Logs from api7-ingress-controller
shell: bash
run: |
export KUBECONFIG=/tmp/apisix-ingress-cluster.kubeconfig
kubectl logs -n apisix-conformance-test -l app=apisix-ingress-controller

- name: Upload Gateway API Conformance Report
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v4
with:
name: apisix-ingress-controller-conformance-report.yaml
path: apisix-ingress-controller-conformance-report.yaml

- name: Format Conformance Test Report
if: ${{ github.event_name == 'pull_request' }}
run: |
echo '# conformance test report' > report.md
echo '```yaml' >> report.md
cat apisix-ingress-controller-conformance-report.yaml >> report.md
echo '```' >> report.md

- name: Report Conformance Test Result to PR Comment
if: ${{ github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v2
with:
message-id: '${{ matrix.target }}'
message-path: |
report.md
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ download-api7ee3-chart:
conformance-test:
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test -v ./test/conformance -tags=conformance -timeout 60m

.PHONY: conformance-test-standalone
conformance-test-standalone:
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
go test -v ./test/conformance/apisix -tags=conformance -timeout 60m

.PHONY: lint
lint: sort-import golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run
Expand Down
78 changes: 78 additions & 0 deletions test/conformance/apisix/conformance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//go:build conformance
// +build conformance

package conformance

import (
"flag"
"os"
"testing"

"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/gateway-api/conformance"
conformancev1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
"sigs.k8s.io/yaml"
)

var skippedTestsForSSL = []string{
// Reason: https://github.com/kubernetes-sigs/gateway-api/blob/5c5fc388829d24e8071071b01e8313ada8f15d9f/conformance/utils/suite/suite.go#L358. SAN includes '*'
tests.HTTPRouteHTTPSListener.ShortName,
tests.HTTPRouteRedirectPortAndScheme.ShortName,
}

// TODO: HTTPRoute hostname intersection and listener hostname matching

var gatewaySupportedFeatures = []features.FeatureName{
features.SupportGateway,
features.SupportHTTPRoute,
// features.SupportHTTPRouteMethodMatching,
// features.SupportHTTPRouteResponseHeaderModification,
// features.SupportHTTPRouteRequestMirror,
// features.SupportHTTPRouteBackendRequestHeaderModification,
// features.SupportHTTPRouteHostRewrite,
}

func TestGatewayAPIConformance(t *testing.T) {
flag.Parse()

opts := conformance.DefaultOptions(t)
opts.Debug = true
opts.CleanupBaseResources = true
opts.GatewayClassName = gatewayClassName
opts.SupportedFeatures = sets.New(gatewaySupportedFeatures...)
opts.SkipTests = skippedTestsForSSL
opts.Implementation = conformancev1.Implementation{
Organization: "APISIX",
Project: "apisix-ingress-controller",
URL: "https://github.com/apache/apisix-ingress-controller.git",
Version: "v2.0.0",
}
opts.ConformanceProfiles = sets.New(suite.GatewayHTTPConformanceProfileName)

cSuite, err := suite.NewConformanceTestSuite(opts)
require.NoError(t, err)

t.Log("starting the gateway conformance test suite")
cSuite.Setup(t, tests.ConformanceTests)

if err := cSuite.Run(t, tests.ConformanceTests); err != nil {
t.Fatalf("failed to run the gateway conformance test suite: %v", err)
}

const reportFileName = "apisix-ingress-controller-conformance-report.yaml"
report, err := cSuite.Report()
if err != nil {
t.Fatalf("failed to get the gateway conformance test report: %v", err)
}

rawReport, err := yaml.Marshal(report)
if err != nil {
t.Fatalf("failed to marshal the gateway conformance test report: %v", err)
}
// Save report in the root of the repository, file name is in .gitignore.
require.NoError(t, os.WriteFile("../../../"+reportFileName, rawReport, 0o600))
}
Loading
Loading