Skip to content

Commit

Permalink
chore: update TestDeployment (#2721)
Browse files Browse the repository at this point in the history
* chore: update TestDeployment

Signed-off-by: zirain <[email protected]>

* lint

Signed-off-by: zirain <[email protected]>

* use go.testdata.complete

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: zirain <[email protected]>
Co-authored-by: Xunzhuo <[email protected]>
  • Loading branch information
zirain and Xunzhuo authored Feb 29, 2024
1 parent fa6b0d4 commit f6ae81f
Show file tree
Hide file tree
Showing 21 changed files with 4,346 additions and 3,897 deletions.
28 changes: 18 additions & 10 deletions internal/infrastructure/kubernetes/proxy/resource_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package proxy

import (
"flag"
"fmt"
"os"
"sort"
Expand All @@ -29,6 +30,10 @@ import (
"github.com/envoyproxy/gateway/internal/ir"
)

var (
overrideTestData = flag.Bool("override-testdata", false, "if override the test output data.")
)

const (
// envoyHTTPPort is the container port number of Envoy's HTTP endpoint.
envoyHTTPPort = int32(8080)
Expand Down Expand Up @@ -333,11 +338,13 @@ func TestDeployment(t *testing.T) {
bootstrap: `test bootstrap config`,
},
{
caseName: "enable-prometheus",
caseName: "disable-prometheus",
infra: newTestInfra(),
telemetry: &egv1a1.ProxyTelemetry{
Metrics: &egv1a1.ProxyMetrics{
Prometheus: &egv1a1.ProxyPrometheusProvider{},
Prometheus: &egv1a1.ProxyPrometheusProvider{
Disable: true,
},
},
},
},
Expand Down Expand Up @@ -509,14 +516,6 @@ func TestDeployment(t *testing.T) {

if tc.telemetry != nil {
tc.infra.Proxy.Config.Spec.Telemetry = tc.telemetry
} else {
tc.infra.Proxy.Config.Spec.Telemetry = &egv1a1.ProxyTelemetry{
Metrics: &egv1a1.ProxyMetrics{
Prometheus: &egv1a1.ProxyPrometheusProvider{
Disable: true,
},
},
}
}

if len(tc.proxyLogging) > 0 {
Expand Down Expand Up @@ -550,6 +549,15 @@ func TestDeployment(t *testing.T) {
})
}

if *overrideTestData {
deploymentYAML, err := yaml.Marshal(dp)
require.NoError(t, err)
// nolint: gosec
err = os.WriteFile(fmt.Sprintf("testdata/deployments/%s.yaml", tc.caseName), deploymentYAML, 0644)
require.NoError(t, err)
return
}

sortEnv(dp.Spec.Template.Spec.Containers[0].Env)
sortEnv(expected.Spec.Template.Spec.Containers[0].Env)
assert.Equal(t, expected, dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,161 +1,171 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
app.kubernetes.io/name: envoy
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
name: envoy-default-37a8eec1
namespace: envoy-gateway-system
spec:
progressDeadlineSeconds: 600
replicas: 1
strategy:
type: RollingUpdate
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
app.kubernetes.io/name: envoy
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
strategy:
type: RollingUpdate
template:
metadata:
annotations:
prometheus.io/path: /stats/prometheus
prometheus.io/port: "19001"
prometheus.io/scrape: "true"
creationTimestamp: null
labels:
app.kubernetes.io/name: envoy
app.kubernetes.io/component: proxy
app.kubernetes.io/managed-by: envoy-gateway
app.kubernetes.io/name: envoy
gateway.envoyproxy.io/owning-gateway-name: default
gateway.envoyproxy.io/owning-gateway-namespace: default
spec:
automountServiceAccountToken: false
containers:
- args:
- --service-cluster default
- --service-node $(ENVOY_POD_NAME)
- --config-yaml test bootstrap config
- --log-level warn
- --cpuset-threads
command:
- envoy
env:
- name: ENVOY_GATEWAY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: ENVOY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: envoyproxy/envoy:distroless-dev
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
httpGet:
path: /shutdown/ready
port: 19002
scheme: HTTP
name: envoy
ports:
- containerPort: 8080
name: EnvoyH-d76a15e2
protocol: TCP
- containerPort: 8443
name: EnvoyH-6658f727
protocol: TCP
resources:
requests:
cpu: 100m
memory: 512Mi
readinessProbe:
httpGet:
path: /ready
port: 19001
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /certs
name: certs
readOnly: true
- mountPath: /sds
name: sds
- args:
- envoy
- shutdown-manager
command:
- envoy-gateway
env:
- name: ENVOY_GATEWAY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: ENVOY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: envoyproxy/gateway-dev:latest
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
exec:
command:
- envoy-gateway
- envoy
- shutdown
name: shutdown-manager
resources:
requests:
cpu: 10m
memory: 32Mi
readinessProbe:
httpGet:
path: /healthz
port: 19002
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
- args:
- --service-cluster default
- --service-node $(ENVOY_POD_NAME)
- --config-yaml test bootstrap config
- --log-level warn
- --cpuset-threads
command:
- envoy
env:
- name: ENVOY_GATEWAY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: ENVOY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: envoyproxy/envoy:distroless-dev
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
httpGet:
path: /healthz
path: /shutdown/ready
port: 19002
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
name: envoy
ports:
- containerPort: 8080
name: EnvoyH-d76a15e2
protocol: TCP
- containerPort: 8443
name: EnvoyH-6658f727
protocol: TCP
- containerPort: 19001
name: metrics
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /ready
port: 19001
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 100m
memory: 512Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /certs
name: certs
readOnly: true
- mountPath: /sds
name: sds
- args:
- envoy
- shutdown-manager
command:
- envoy-gateway
env:
- name: ENVOY_GATEWAY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: ENVOY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: envoyproxy/gateway-dev:latest
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
exec:
command:
- envoy-gateway
- envoy
- shutdown
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 19002
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: shutdown-manager
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 19002
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 10m
memory: 32Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
serviceAccountName: envoy-default-37a8eec1
terminationGracePeriodSeconds: 900
volumes:
- name: certs
secret:
secretName: envoy
defaultMode: 420
- configMap:
defaultMode: 420
items:
- key: xds-trusted-ca.json
path: xds-trusted-ca.json
- key: xds-certificate.json
path: xds-certificate.json
name: envoy-default-37a8eec1
optional: false
name: sds
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
- name: certs
secret:
defaultMode: 420
secretName: envoy
- configMap:
defaultMode: 420
items:
- key: xds-trusted-ca.json
path: xds-trusted-ca.json
- key: xds-certificate.json
path: xds-certificate.json
name: envoy-default-37a8eec1
optional: false
name: sds
status: {}
Loading

0 comments on commit f6ae81f

Please sign in to comment.