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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: http-infra-backend-v1
name: accesslog-file
namespace: gateway-conformance-infra
spec:
parentRefs:
Expand All @@ -10,7 +10,7 @@ spec:
- matches:
- path:
type: PathPrefix
value: /
value: /file
backendRefs:
- name: infra-backend-v1
port: 8080
16 changes: 16 additions & 0 deletions test/e2e/testdata/accesslog-otel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: accesslog-otel
namespace: gateway-conformance-infra
spec:
parentRefs:
- name: same-namespace
rules:
- matches:
- path:
type: PathPrefix
value: /otel
backendRefs:
- name: infra-backend-v2
port: 8080
46 changes: 16 additions & 30 deletions test/e2e/tests/accesslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ func init() {
var FileAccessLogTest = suite.ConformanceTest{
ShortName: "FileAccessLog",
Description: "Make sure file access log is working",
Manifests: []string{"testdata/accesslog.yaml"},
Manifests: []string{"testdata/accesslog-file.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("Stdout", func(t *testing.T) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "http-infra-backend-v1", Namespace: ns}
routeNN := types.NamespacedName{Name: "accesslog-file", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

// make sure listener is ready
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, httputils.ExpectedResponse{
expectedResponse := httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/",
Path: "/file",
},
Response: httputils.Response{
StatusCode: 200,
},
Namespace: ns,
})
}
// make sure listener is ready
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)

labels := map[string]string{
"job": "fluentbit",
Expand Down Expand Up @@ -90,15 +91,7 @@ var FileAccessLogTest = suite.ConformanceTest{
return false, nil
}

httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/",
},
Response: httputils.Response{
StatusCode: 200,
},
Namespace: ns,
})
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)

// it will take some time for fluent-bit to collect the log and send to loki
// let's wait for a while
Expand Down Expand Up @@ -133,24 +126,25 @@ var FileAccessLogTest = suite.ConformanceTest{
var OpenTelemetryTest = suite.ConformanceTest{
ShortName: "OpenTelemetryAccessLog",
Description: "Make sure OpenTelemetry access log is working",
Manifests: []string{"testdata/accesslog.yaml"},
Manifests: []string{"testdata/accesslog-otel.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("OTel", func(t *testing.T) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "http-infra-backend-v1", Namespace: ns}
routeNN := types.NamespacedName{Name: "accesslog-otel", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

// make sure listener is ready
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, httputils.ExpectedResponse{
expectedResponse := httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/",
Path: "/otel",
},
Response: httputils.Response{
StatusCode: 200,
},
Namespace: ns,
})
}
// make sure listener is ready
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)

labels := map[string]string{
"k8s_namespace_name": "envoy-gateway-system",
Expand All @@ -167,15 +161,7 @@ var OpenTelemetryTest = suite.ConformanceTest{
return false, nil
}

httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/",
},
Response: httputils.Response{
StatusCode: 200,
},
Namespace: ns,
})
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)

if err := wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 10*time.Second, true, func(_ context.Context) (bool, error) {
count, err := QueryLogCountFromLoki(t, suite.Client, types.NamespacedName{
Expand Down