Skip to content

Commit

Permalink
tests: run conformance on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed May 23, 2024
1 parent e8c2778 commit 32ef482
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 37 deletions.
63 changes: 30 additions & 33 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,39 +175,36 @@ jobs:
name: tests-report
path: unit-tests.xml

# TODO: https://github.com/Kong/gateway-operator/issues/1411
# conformance-tests:
# runs-on: ubuntu-latest
# steps:
# - name: checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: setup golang
# uses: actions/setup-go@v5
# with:
# go-version-file: go.mod

# - name: run conformance tests
# run: make test.conformance
# env:
# GOTESTSUM_JUNITFILE: "conformance-tests.xml"

# - name: upload diagnostics
# if: ${{ always() }}
# uses: actions/upload-artifact@v4
# with:
# name: diagnostics-conformance
# path: /tmp/ktf-diag*
# if-no-files-found: ignore

# - name: collect test report
# if: ${{ always() }}
# uses: actions/upload-artifact@v3
# with:
# name: tests-report
# path: conformance-tests.xml
conformance-tests:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: run conformance tests
run: make test.conformance
env:
GOTESTSUM_JUNITFILE: "conformance-tests.xml"

- name: upload diagnostics
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: diagnostics-conformance
path: /tmp/ktf-diag*
if-no-files-found: ignore

- name: collect test report
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: tests-report
path: conformance-tests.xml

integration-tests:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions internal/types/gatewaytypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type (
ParentReference = gatewayv1.ParentReference
CommonRouteSpec = gatewayv1.CommonRouteSpec
Kind = gatewayv1.Kind
Namespace = gatewayv1.Namespace
Group = gatewayv1.Group
AllowedRoutes = gatewayv1.AllowedRoutes
RouteGroupKind = gatewayv1.RouteGroupKind
Expand Down
93 changes: 89 additions & 4 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"path"
"testing"

"github.com/google/uuid"
"github.com/samber/lo"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand All @@ -15,7 +17,9 @@ import (
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"

v1beta1 "github.com/kong/gateway-operator/api/v1beta1"
"github.com/kong/gateway-operator/internal/metadata"
gwtypes "github.com/kong/gateway-operator/internal/types"
testutils "github.com/kong/gateway-operator/pkg/utils/test"
"github.com/kong/gateway-operator/pkg/vars"
)
Expand All @@ -40,18 +44,99 @@ func TestGatewayConformance(t *testing.T) {
t.Parallel()

t.Log("creating GatewayClass for gateway conformance tests")
gwconf := v1beta1.GatewayConfiguration{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "kgo-gwconf-conformance-",
Namespace: "default",
},
Spec: v1beta1.GatewayConfigurationSpec{
DataPlaneOptions: &v1beta1.GatewayConfigDataPlaneOptions{
Deployment: v1beta1.DataPlaneDeploymentOptions{
DeploymentOptions: v1beta1.DeploymentOptions{
PodTemplateSpec: &corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "proxy",
ReadinessProbe: &corev1.Probe{
InitialDelaySeconds: 1,
PeriodSeconds: 1,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("10m"),
corev1.ResourceMemory: resource.MustParse("128Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("500m"),
corev1.ResourceMemory: resource.MustParse("1024Mi"),
},
},
},
},
},
},
},
},
},
ControlPlaneOptions: &v1beta1.ControlPlaneOptions{
Deployment: v1beta1.ControlPlaneDeploymentOptions{
PodTemplateSpec: &corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "controller",
ReadinessProbe: &corev1.Probe{
InitialDelaySeconds: 1,
PeriodSeconds: 1,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("10m"),
corev1.ResourceMemory: resource.MustParse("32Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("200m"),
corev1.ResourceMemory: resource.MustParse("256Mi"),
},
},
Env: []corev1.EnvVar{
{
Name: "CONTROLLER_LOG_LEVEL",
Value: "debug",
},
},
},
},
},
},
},
},
},
}
require.NoError(t, clients.MgrClient.Create(ctx, &gwconf))
t.Cleanup(func() {
require.NoError(t, clients.MgrClient.Delete(ctx, &gwconf))
})

gwc := &gatewayv1.GatewayClass{
ObjectMeta: metav1.ObjectMeta{
Name: uuid.NewString(),
GenerateName: "kgo-gwclass-conformance-",
},
Spec: gatewayv1.GatewayClassSpec{
ControllerName: gatewayv1.GatewayController(vars.ControllerName()),
ParametersRef: &gatewayv1.ParametersReference{
Group: "gateway-operator.konghq.com",
Kind: "GatewayConfiguration",
Name: gwconf.Name,
Namespace: lo.ToPtr(gwtypes.Namespace("default")),
},
},
}
require.NoError(t, clients.MgrClient.Create(ctx, gwc))
defer func() {
t.Cleanup(func() {
require.NoError(t, clients.MgrClient.Delete(ctx, gwc))
}()
})

// There are no explicit conformance tests for GatewayClass, but we can
// still run the conformance test suite setup to ensure that the
Expand Down

0 comments on commit 32ef482

Please sign in to comment.