Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use envoy xds server type in daily e2e tests #4100

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
70 changes: 70 additions & 0 deletions .github/workflows/build_daily.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Daily build

on:
# Run every day
schedule:
- cron: '0 12 * * *'

env:
GOPROXY: https://proxy.golang.org/
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
e2e-envoy-xds:
runs-on: ubuntu-latest
needs: [build-image]
strategy:
matrix:
# use stable kubernetes_version values since they're included
# in the name of the GitHub Actions job, and we don't want to
# have to update branch protection rules every time we change
# a Kubernetes version number.
kubernetes_version: ["kubernetes:latest", "kubernetes:n-1", "kubernetes:n-2"]
# run tests using the configuration crd as well as without
config_type: ["ConfigmapConfiguration", "ContourConfiguration"]
# include defines an additional variable (the specific node
# image to use) for each kubernetes_version value.
include:
- kubernetes_version: "kubernetes:latest"
node_image: "docker.io/kindest/node:v1.22.0@sha256:f97edf7f7ed53c57762b24f90a34fad101386c5bd4d93baeb45449557148c717"
- kubernetes_version: "kubernetes:n-1"
node_image: "docker.io/kindest/node:v1.21.2@sha256:9d07ff05e4afefbba983fac311807b3c17a5f36e7061f6cb7e2ba756255b2be4"
- kubernetes_version: "kubernetes:n-2"
node_image: "docker.io/kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9"
- config_type: "ConfigmapConfiguration"
use_config_crd: "false"
- config_type: "ContourConfiguration"
use_config_crd: "true"

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-${{ github.job }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ github.job }}-go-
- uses: actions/setup-go@v2
with:
go-version: '1.17.5'
- name: add deps to path
run: |
./hack/actions/install-kubernetes-toolchain.sh $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: e2e tests
env:
NODEIMAGE: ${{ matrix.node_image }}
USE_CONTOUR_CONFIGURATION_CRD: ${{ matrix.use_config_crd }}
CONTOUR_E2E_IMAGE: ghcr.io/projectcontour/contour:main
CONTOUR_E2E_XDS_SERVER_TYPE: envoy
run: |
make e2e
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#contour-ci-notifications'
if: ${{ failure() && github.ref == 'refs/heads/main' }}
11 changes: 4 additions & 7 deletions test/e2e/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,10 @@ func (d *Deployment) StartLocalContour(config *config.Parameters, contourConfigu
contourConfiguration.Name = randomString(14)

// Set the xds server to the defined testing port as well as enable insecure communication.
contourConfiguration.Spec.XDSServer = contour_api_v1alpha1.XDSServerConfig{
Type: contour_api_v1alpha1.ContourServerType,
Address: "0.0.0.0",
Port: port,
TLS: &contour_api_v1alpha1.TLS{
Insecure: true,
},
contourConfiguration.Spec.XDSServer.Port = port
contourConfiguration.Spec.XDSServer.Address = "0.0.0.0"
contourConfiguration.Spec.XDSServer.TLS = &contour_api_v1alpha1.TLS{
Insecure: true,
}

if err := d.client.Create(context.TODO(), contourConfiguration); err != nil {
Expand Down
36 changes: 34 additions & 2 deletions test/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package e2e

import (
"context"

contour_api_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1"
"os"

"github.com/onsi/ginkgo"
contour_api_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1"
"github.com/projectcontour/contour/pkg/config"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -326,6 +327,16 @@ func (e *EchoSecure) Deploy(ns, name string) func() {
}
}

// DefaultContourConfigFileParams returns a default configuration in a config
// file params object.
func DefaultContourConfigFileParams() *config.Parameters {
return &config.Parameters{
Server: config.ServerParameters{
XDSServerType: config.ServerType(XDSServerTypeFromEnv()),
},
}
}

// DefaultContourConfiguration returns a default ContourConfiguration object.
func DefaultContourConfiguration() *contour_api_v1alpha1.ContourConfiguration {
return &contour_api_v1alpha1.ContourConfiguration{
Expand All @@ -334,6 +345,17 @@ func DefaultContourConfiguration() *contour_api_v1alpha1.ContourConfiguration {
Namespace: "projectcontour",
},
Spec: contour_api_v1alpha1.ContourConfigurationSpec{
XDSServer: contour_api_v1alpha1.XDSServerConfig{
Type: XDSServerTypeFromEnv(),
Address: "0.0.0.0",
Port: 8001,
TLS: &contour_api_v1alpha1.TLS{
CAFile: "/certs/ca.crt",
CertFile: "/certs/tls.crt",
KeyFile: "/certs/tls.key",
Insecure: false,
},
},
Debug: contour_api_v1alpha1.DebugConfig{
Address: "127.0.0.1",
Port: 6060,
Expand Down Expand Up @@ -409,3 +431,13 @@ func DefaultContourConfiguration() *contour_api_v1alpha1.ContourConfiguration {
func IngressPathTypePtr(val networkingv1.PathType) *networkingv1.PathType {
return &val
}

func XDSServerTypeFromEnv() contour_api_v1alpha1.XDSServerType {
// Default to contour if not provided.
serverType := contour_api_v1alpha1.ContourServerType
typeFromEnv, found := os.LookupEnv("CONTOUR_E2E_XDS_SERVER_TYPE")
if found {
serverType = contour_api_v1alpha1.XDSServerType(typeFromEnv)
}
return serverType
}
7 changes: 5 additions & 2 deletions test/e2e/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ var _ = Describe("Gateway API", func() {
}

// Update contour configuration to point to specified gateway.
contourConfiguration = e2e.DefaultContourConfiguration()
contourConfiguration.Spec.Gateway = &contour_api_v1alpha1.GatewayConfig{
ControllerName: string(gatewayClass.Spec.ControllerName),
}
Expand All @@ -101,7 +100,11 @@ var _ = Describe("Gateway API", func() {
BeforeEach(func() {
// Contour config file contents, can be modified in nested
// BeforeEach.
contourConfig = &config.Parameters{}
contourConfig = e2e.DefaultContourConfigFileParams()

// Contour configuration crd, can be modified in nested
// BeforeEach.
contourConfiguration = e2e.DefaultContourConfiguration()

// Default contour serve command line arguments can be appended to in
// nested BeforeEach.
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/gateway/multiple_gateways_and_classes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ var _ = Describe("GatewayClass/Gateway admission tests", func() {

// Contour config file contents, can be modified in nested
// BeforeEach.
contourConfig = &config.Parameters{
GatewayConfig: &config.GatewayParameters{
ControllerName: controllerName,
},
contourConfig = e2e.DefaultContourConfigFileParams()
contourConfig.GatewayConfig = &config.GatewayParameters{
ControllerName: controllerName,
}

// Update contour configuration to point to specified gateway.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/httpproxy/httpproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var _ = Describe("HTTPProxy", func() {
BeforeEach(func() {
// Contour config file contents, can be modified in nested
// BeforeEach.
contourConfig = &config.Parameters{}
contourConfig = e2e.DefaultContourConfigFileParams()

// Contour configuration crd, can be modified in nested
// BeforeEach.
Expand Down
25 changes: 24 additions & 1 deletion test/e2e/incluster/incluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package incluster

import (
"context"
"strings"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
contour_api_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1"
"github.com/projectcontour/contour/test/e2e"
"github.com/stretchr/testify/require"
)
Expand All @@ -33,6 +36,17 @@ func TestIncluster(t *testing.T) {
}

var _ = BeforeSuite(func() {
// Default to using ContourConfiguration CRD.
originalArgs := f.Deployment.ContourDeployment.Spec.Template.Spec.Containers[0].Args
var newArgs []string
for _, arg := range originalArgs {
if !strings.Contains(arg, "--config-path") {
newArgs = append(newArgs, arg)
}
}
newArgs = append(newArgs, "--contour-config-name=incluster-tests")
f.Deployment.ContourDeployment.Spec.Template.Spec.Containers[0].Args = newArgs

require.NoError(f.T(), f.Deployment.EnsureResourcesForInclusterContour(false))
})

Expand All @@ -44,9 +58,17 @@ var _ = AfterSuite(func() {
})

var _ = Describe("Incluster", func() {
var contourConfig *contour_api_v1alpha1.ContourConfiguration

BeforeEach(func() {
contourConfig = e2e.DefaultContourConfiguration()
contourConfig.Name = "incluster-tests"
})

JustBeforeEach(func() {
// Create contour deployment here so we can modify or do other
// Create contour deployment and config here so we can modify or do other
// actions in BeforeEach.
require.NoError(f.T(), f.Client.Create(context.TODO(), contourConfig))
require.NoError(f.T(), f.Deployment.EnsureContourDeployment())
require.NoError(f.T(), f.Deployment.WaitForContourDeploymentUpdated())
require.NoError(f.T(), f.Deployment.WaitForEnvoyDaemonSetUpdated())
Expand All @@ -55,6 +77,7 @@ var _ = Describe("Incluster", func() {
AfterEach(func() {
// Clean out contour after each test.
require.NoError(f.T(), f.Deployment.EnsureDeleted(f.Deployment.ContourDeployment))
require.NoError(f.T(), f.Deployment.EnsureDeleted(contourConfig))
})

f.NamespacedTest("smoke-test", testSimpleSmoke)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/infra/infra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Describe("Infra", func() {
BeforeEach(func() {
// Contour config file contents, can be modified in nested
// BeforeEach.
contourConfig = &config.Parameters{}
contourConfig = e2e.DefaultContourConfigFileParams()

// Contour configuration crd, can be modified in nested
// BeforeEach.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("Ingress", func() {
BeforeEach(func() {
// Contour config file contents, can be modified in nested
// BeforeEach.
contourConfig = &config.Parameters{}
contourConfig = e2e.DefaultContourConfigFileParams()

contourConfiguration = e2e.DefaultContourConfiguration()

Expand Down