Skip to content

Commit de8abd5

Browse files
authored
(backport) chore: add more conformance-test report for gateway-api (#2557) (#263)
1 parent fc6862f commit de8abd5

File tree

7 files changed

+128
-126
lines changed

7 files changed

+128
-126
lines changed

.github/workflows/apisix-conformance-test.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ permissions:
3434

3535
jobs:
3636
conformance-test:
37+
env:
38+
CONFORMANCE_TEST_REPORT_OUTPUT: /tmp/apisix-ingress-controller-conformance-report.yaml
3739
timeout-minutes: 60
3840
strategy:
3941
matrix:
@@ -62,6 +64,10 @@ jobs:
6264
username: ${{ secrets.DOCKER_USERNAME }}
6365
password: ${{ secrets.DOCKER_PASSWORD }}
6466

67+
- name: Install kind
68+
run: |
69+
go install sigs.k8s.io/[email protected]
70+
6571
- name: Build images
6672
env:
6773
TAG: dev
@@ -97,27 +103,31 @@ jobs:
97103
env:
98104
PROVIDER_TYPE: ${{ matrix.provider_type }}
99105
run: |
100-
make conformance-test-standalone
106+
make conformance-test
101107
102-
- name: Get Logs from api7-ingress-controller
108+
- name: Show Conformance Report
109+
shell: bash
110+
run: |
111+
cat ${CONFORMANCE_TEST_REPORT_OUTPUT}
112+
113+
- name: Get Logs from apisix-ingress-controller
103114
shell: bash
104115
run: |
105116
export KUBECONFIG=/tmp/apisix-ingress-cluster.kubeconfig
106117
kubectl logs -n apisix-conformance-test -l app=apisix-ingress-controller
107118
108119
- name: Upload Gateway API Conformance Report
109-
if: ${{ github.event_name == 'push' }}
110120
uses: actions/upload-artifact@v4
111121
with:
112122
name: apisix-ingress-controller-conformance-report-${{ matrix.provider_type }}.yaml
113-
path: apisix-ingress-controller-conformance-report.yaml
123+
path: ${{ env.CONFORMANCE_TEST_REPORT_OUTPUT }}
114124

115125
- name: Format Conformance Test Report
116126
if: ${{ github.event_name == 'pull_request' }}
117127
run: |
118128
echo '# conformance test report - ${{ matrix.provider_type }} mode' > report.md
119129
echo '```yaml' >> report.md
120-
cat apisix-ingress-controller-conformance-report.yaml >> report.md
130+
cat ${CONFORMANCE_TEST_REPORT_OUTPUT} >> report.md
121131
echo '```' >> report.md
122132
123133
- name: Report Conformance Test Result to PR Comment

.github/workflows/conformance-test.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ concurrency:
3131

3232
jobs:
3333
conformance-test:
34+
env:
35+
CONFORMANCE_TEST_REPORT_OUTPUT: /tmp/api7-ingress-controller-conformance-report.yaml
3436
timeout-minutes: 60
3537
runs-on: ubuntu-latest
3638
steps:
@@ -105,8 +107,13 @@ jobs:
105107
API7_EE_LICENSE: ${{ secrets.API7_EE_LICENSE }}
106108
continue-on-error: true
107109
run: |
108-
make conformance-test
110+
make conformance-test-api7ee
109111
112+
- name: Show Conformance Report
113+
shell: bash
114+
run: |
115+
cat ${CONFORMANCE_TEST_REPORT_OUTPUT}
116+
110117
- name: Get Logs from api7-ingress-controller
111118
shell: bash
112119
run: |
@@ -117,20 +124,20 @@ jobs:
117124
if: ${{ github.event_name == 'push' }}
118125
uses: actions/upload-artifact@v4
119126
with:
120-
name: apisix-ingress-controller-conformance-report.yaml
121-
path: apisix-ingress-controller-conformance-report.yaml
127+
name: api7-ingress-controller-conformance-report.yaml
128+
path: ${{ env.CONFORMANCE_TEST_REPORT_OUTPUT }}
122129

123130
- name: Format Conformance Test Report
124131
if: ${{ github.event_name == 'pull_request' }}
125132
run: |
126133
echo '# conformance test report' > report.md
127134
echo '```yaml' >> report.md
128-
cat apisix-ingress-controller-conformance-report.yaml >> report.md
135+
cat ${CONFORMANCE_TEST_REPORT_OUTPUT} >> report.md
129136
echo '```' >> report.md
130137
131138
- name: Report Conformance Test Result to PR Comment
132139
if: ${{ github.event_name == 'pull_request' }}
133-
uses: mshick/add-pr-comment@v2
140+
uses: ./.github/actions/add-pr-comment
134141
with:
135142
message-id: 'conformance-test-report'
136143
message-path: |

Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ ENVTEST_K8S_VERSION = 1.30.0
2929
KIND_NAME ?= apisix-ingress-cluster
3030
KIND_NODE_IMAGE ?= kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
3131

32-
GATEAY_API_VERSION ?= v1.3.0
3332
DASHBOARD_VERSION ?= dev
3433
ADC_VERSION ?= 0.21.0
3534

35+
DIR := $(shell pwd)
36+
3637
GINKGO_VERSION ?= 2.20.0
3738
TEST_TIMEOUT ?= 80m
3839
TEST_DIR ?= ./test/e2e/
@@ -55,6 +56,14 @@ GITSHASYM="github.com/apache/apisix-ingress-controller/internal/version._buildGi
5556
BUILDOSSYM="github.com/apache/apisix-ingress-controller/internal/version._buildOS"
5657
GO_LDFLAGS ?= "-X=$(VERSYM)=$(VERSION) -X=$(GITSHASYM)=$(GITSHA) -X=$(BUILDOSSYM)=$(OSNAME)/$(OSARCH)"
5758

59+
# gateway-api
60+
GATEAY_API_VERSION ?= v1.3.0
61+
## https://github.com/kubernetes-sigs/gateway-api/blob/v1.3.0/pkg/features/httproute.go
62+
SUPPORTED_EXTENDED_FEATURES = "HTTPRouteDestinationPortMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteRequestMirror,HTTPRouteSchemeRedirect,GatewayAddressEmpty,HTTPRouteResponseHeaderModification,GatewayPort8080"
63+
CONFORMANCE_TEST_REPORT_OUTPUT ?= $(DIR)/apisix-ingress-controller-conformance-report.yaml
64+
## https://github.com/kubernetes-sigs/gateway-api/blob/v1.3.0/conformance/utils/suite/profiles.go
65+
CONFORMANCE_PROFILES ?= GATEWAY-HTTP
66+
5867
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5968
ifeq (,$(shell go env GOBIN))
6069
GOBIN=$(shell go env GOPATH)/bin
@@ -154,12 +163,18 @@ install-ginkgo:
154163

155164
.PHONY: conformance-test
156165
conformance-test:
157-
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test -v ./test/conformance -tags=conformance -timeout 60m
158-
159-
.PHONY: conformance-test-standalone
160-
conformance-test-standalone:
161-
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
162-
go test -v ./test/conformance/apisix -tags=conformance -timeout 60m
166+
go test -v ./test/conformance -tags conformance,experimental -timeout 60m \
167+
--supported-features=$(SUPPORTED_EXTENDED_FEATURES) \
168+
--conformance-profiles=$(CONFORMANCE_PROFILES) \
169+
--report-output=$(CONFORMANCE_TEST_REPORT_OUTPUT)
170+
171+
172+
.PHONY: conformance-test-api7ee
173+
conformance-test-api7ee:
174+
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test -v ./test/conformance/api7ee -tags conformance,experimental -timeout 60m \
175+
--supported-features=$(SUPPORTED_EXTENDED_FEATURES) \
176+
--conformance-profiles=$(CONFORMANCE_PROFILES) \
177+
--report-output=$(CONFORMANCE_TEST_REPORT_OUTPUT)
163178

164179
.PHONY: lint
165180
lint: sort-import golangci-lint ## Run golangci-lint linter

test/conformance/apisix/conformance_test.go renamed to test/conformance/api7ee/conformance_test.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
//go:build conformance
19-
// +build conformance
20-
21-
package conformance
18+
package api7ee
2219

2320
import (
24-
"flag"
2521
"os"
2622
"testing"
2723

@@ -30,8 +26,8 @@ import (
3026
"sigs.k8s.io/gateway-api/conformance"
3127
conformancev1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
3228
"sigs.k8s.io/gateway-api/conformance/tests"
29+
"sigs.k8s.io/gateway-api/conformance/utils/flags"
3330
"sigs.k8s.io/gateway-api/conformance/utils/suite"
34-
"sigs.k8s.io/gateway-api/pkg/features"
3531
"sigs.k8s.io/yaml"
3632
)
3733

@@ -43,24 +39,11 @@ var skippedTestsForSSL = []string{
4339

4440
// TODO: HTTPRoute hostname intersection and listener hostname matching
4541

46-
var gatewaySupportedFeatures = []features.FeatureName{
47-
features.SupportGateway,
48-
features.SupportHTTPRoute,
49-
// features.SupportHTTPRouteMethodMatching,
50-
// features.SupportHTTPRouteResponseHeaderModification,
51-
// features.SupportHTTPRouteRequestMirror,
52-
// features.SupportHTTPRouteBackendRequestHeaderModification,
53-
// features.SupportHTTPRouteHostRewrite,
54-
}
55-
5642
func TestGatewayAPIConformance(t *testing.T) {
57-
flag.Parse()
58-
5943
opts := conformance.DefaultOptions(t)
6044
opts.Debug = true
6145
opts.CleanupBaseResources = true
6246
opts.GatewayClassName = gatewayClassName
63-
opts.SupportedFeatures = sets.New(gatewaySupportedFeatures...)
6447
opts.SkipTests = skippedTestsForSSL
6548
opts.Implementation = conformancev1.Implementation{
6649
Organization: "APISIX",
@@ -80,7 +63,6 @@ func TestGatewayAPIConformance(t *testing.T) {
8063
t.Fatalf("failed to run the gateway conformance test suite: %v", err)
8164
}
8265

83-
const reportFileName = "apisix-ingress-controller-conformance-report.yaml"
8466
report, err := cSuite.Report()
8567
if err != nil {
8668
t.Fatalf("failed to get the gateway conformance test report: %v", err)
@@ -90,6 +72,10 @@ func TestGatewayAPIConformance(t *testing.T) {
9072
if err != nil {
9173
t.Fatalf("failed to marshal the gateway conformance test report: %v", err)
9274
}
93-
// Save report in the root of the repository, file name is in .gitignore.
94-
require.NoError(t, os.WriteFile("../../../"+reportFileName, rawReport, 0o600))
75+
f, err := os.Create(*flags.ReportOutput)
76+
require.NoError(t, err)
77+
defer func() { _ = f.Close() }()
78+
79+
_, err = f.Write(rawReport)
80+
require.NoError(t, err)
9581
}

test/conformance/apisix/suite_test.go renamed to test/conformance/api7ee/suite_test.go

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package conformance
18+
package api7ee
1919

2020
import (
2121
"context"
@@ -32,7 +32,6 @@ import (
3232
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
3333

3434
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
35-
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
3635
)
3736

3837
var gatewayClassName = "apisix"
@@ -124,8 +123,7 @@ func TestMain(m *testing.M) {
124123
RegisterFailHandler(Fail)
125124
f := framework.NewFramework()
126125

127-
// init newDeployer function
128-
scaffold.NewDeployer = scaffold.NewAPISIXDeployer
126+
f.BeforeSuite()
129127

130128
// Check and delete specific namespaces if they exist
131129
kubectl := k8s.NewKubectlOptions("", "", "default")
@@ -138,51 +136,49 @@ func TestMain(m *testing.M) {
138136
k8s.CreateNamespace(GinkgoT(), kubectl, namespace)
139137
defer k8s.DeleteNamespace(GinkgoT(), kubectl, namespace)
140138

141-
adminkey := getEnvOrDefault("APISIX_ADMIN_KEY", "edd1c9f034335f136f87ad84b625c8f1")
142-
controllerName := "apisix.apache.org/apisix-ingress-controller"
143-
s := scaffold.NewScaffold(scaffold.Options{
144-
ControllerName: controllerName,
145-
SkipHooks: true,
146-
APISIXAdminAPIKey: adminkey,
139+
gatewayGroupId := f.CreateNewGatewayGroupWithIngress()
140+
adminKey := f.GetAdminKey(gatewayGroupId)
141+
142+
svc := f.DeployGateway(&framework.API7DeployOptions{
143+
Namespace: namespace,
144+
GatewayGroupID: gatewayGroupId,
145+
DPManagerEndpoint: framework.DPManagerTLSEndpoint,
146+
SetEnv: true,
147+
SSLKey: framework.TestKey,
148+
SSLCert: framework.TestCert,
149+
TLSEnabled: true,
150+
ForIngressGatewayGroup: true,
151+
ServiceType: "LoadBalancer",
152+
ServiceHTTPPort: 80,
153+
ServiceHTTPSPort: 443,
147154
})
148155

149-
s.Deployer.DeployDataplane(scaffold.DeployDataplaneOptions{
150-
AdminKey: adminkey,
151-
Namespace: namespace,
152-
SkipCreateTunnels: true,
153-
ServiceType: "LoadBalancer",
154-
ServiceHTTPPort: 80,
155-
ServiceHTTPSPort: 443,
156-
})
157-
svc := s.GetDataplaneService()
158-
159156
if len(svc.Status.LoadBalancer.Ingress) == 0 {
160157
Fail("No LoadBalancer found for the service")
161158
}
162159

163160
address := svc.Status.LoadBalancer.Ingress[0].IP
164161

165162
f.DeployIngress(framework.IngressDeployOpts{
166-
ControllerName: controllerName,
167-
Namespace: namespace,
168-
StatusAddress: address,
169-
InitSyncDelay: 20 * time.Minute,
170-
ProviderType: framework.ProviderType,
171-
ProviderSyncPeriod: 1 * time.Hour,
163+
ControllerName: "apisix.apache.org/apisix-ingress-controller",
164+
Namespace: namespace,
165+
StatusAddress: address,
166+
InitSyncDelay: 1 * time.Minute,
167+
ProviderType: "api7ee",
172168
})
173169

174-
adminEndpoint := fmt.Sprintf("http://%s.%s:9180", svc.Name, namespace)
175-
176170
defaultGatewayProxyOpts = GatewayProxyOpts{
177171
StatusAddress: address,
178-
AdminKey: adminkey,
179-
AdminEndpoint: adminEndpoint,
172+
AdminKey: adminKey,
173+
AdminEndpoint: framework.DashboardTLSEndpoint,
180174
}
181175

182176
patchGatewaysForConformanceTest(context.Background(), f.K8sClient)
183177

184178
code := m.Run()
185179

180+
f.AfterSuite()
181+
186182
os.Exit(code)
187183
}
188184

@@ -262,11 +258,3 @@ func patchGatewaysForConformanceTest(ctx context.Context, k8sClient client.Clien
262258
}
263259
}()
264260
}
265-
266-
// getEnvOrDefault returns environment variable value or default
267-
func getEnvOrDefault(key, defaultValue string) string {
268-
if value := os.Getenv(key); value != "" {
269-
return value
270-
}
271-
return defaultValue
272-
}

0 commit comments

Comments
 (0)