Browse Source

GHA container test: increase timeout and use medium size runner

- change all container to use medium runner
- avoid build on-the-fly images
- add parallel back to some tests
NET-3914-gha-change-upgrade-test-small-runner
cskh 2 years ago
parent
commit
5670f41309
  1. 16
      .github/workflows/test-integrations.yml
  2. 0
      test/integration/consul-container/assets/Dockerfile-consul-envoy
  3. 0
      test/integration/consul-container/assets/tproxy-startup.sh
  4. 56
      test/integration/consul-container/go.mod
  5. 1065
      test/integration/consul-container/go.sum
  6. 3
      test/integration/consul-container/libs/cluster/app.go
  7. 53
      test/integration/consul-container/libs/service/common.go
  8. 27
      test/integration/consul-container/libs/service/connect.go
  9. 2
      test/integration/consul-container/libs/service/examples.go
  10. 32
      test/integration/consul-container/libs/service/gateway.go
  11. 0
      test/integration/consul-container/test/upgrade/basic/basic_test.go
  12. 0
      test/integration/consul-container/test/upgrade/basic/fullstopupgrade_test.go
  13. 0
      test/integration/consul-container/test/upgrade/basic/healthcheck_test.go
  14. 6
      test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_default_subset_test.go
  15. 0
      test/integration/consul-container/test/upgrade/peering/peering_control_plane_mgw_test.go
  16. 0
      test/integration/consul-container/test/upgrade/peering/peering_http_test.go

16
.github/workflows/test-integrations.yml

@ -375,7 +375,7 @@ jobs:
| jq --compact-output 'map(join(" "))'
} >> "$GITHUB_OUTPUT"
compatibility-integration-test:
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
runs-on: ${{ fromJSON(needs.setup.outputs.compute-medium) }}
needs:
- setup
- dev-build
@ -405,6 +405,8 @@ jobs:
- name: Build consul:local image
run: docker build -t ${{ env.CONSUL_LATEST_IMAGE_NAME }}:local -f ./build-support/docker/Consul-Dev.dockerfile .
- name: Build consul-envoy:target-version image
run: docker build -t consul-envoy:target-version --build-arg CONSUL_IMAGE=${{ env.CONSUL_LATEST_IMAGE_NAME }}:local --build-arg ENVOY_VERSION=1.24.6 -f ./test/integration/consul-container/assets/Dockerfile-consul-envoy ./test/integration/consul-container/assets
- name: Configure GH workaround for ipv6 loopback
if: ${{ !endsWith(github.repository, '-enterprise') }}
run: |
@ -509,7 +511,7 @@ jobs:
} >> "$GITHUB_OUTPUT"
upgrade-integration-test:
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
runs-on: ${{ fromJSON(needs.setup.outputs.compute-medium) }}
needs:
- setup
- dev-build
@ -520,7 +522,7 @@ jobs:
consul-version: [ "1.14", "1.15"]
test-cases: ${{ fromJSON(needs.generate-upgrade-job-matrices.outputs.upgrade-matrix) }}
env:
CONSUL_VERSION: ${{ matrix.consul-version }}
CONSUL_LATEST_VERSION: ${{ matrix.consul-version }}
steps:
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
@ -538,6 +540,10 @@ jobs:
run: chmod +x consul
- name: Build consul:local image
run: docker build -t ${{ env.CONSUL_LATEST_IMAGE_NAME }}:local -f ./build-support/docker/Consul-Dev.dockerfile .
- name: Build consul-envoy:latest-version image
run: docker build -t consul-envoy:latest-version --build-arg CONSUL_IMAGE=docker.mirror.hashicorp.services/${{ env.CONSUL_LATEST_IMAGE_NAME }}:${{ env.CONSUL_LATEST_VERSION }} --build-arg ENVOY_VERSION=1.24.6 -f ./test/integration/consul-container/assets/Dockerfile-consul-envoy ./test/integration/consul-container/assets
- name: Build consul-envoy:target-version image
run: docker build -t consul-envoy:target-version --build-arg CONSUL_IMAGE=${{ env.CONSUL_LATEST_IMAGE_NAME }}:local --build-arg ENVOY_VERSION=1.24.6 -f ./test/integration/consul-container/assets/Dockerfile-consul-envoy ./test/integration/consul-container/assets
- name: Configure GH workaround for ipv6 loopback
if: ${{ !endsWith(github.repository, '-enterprise') }}
run: |
@ -567,8 +573,8 @@ jobs:
-run "${{ matrix.test-cases }}" \
--target-image ${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--target-version local \
--latest-image ${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--latest-version "${{ env.CONSUL_VERSION }}"
--latest-image docker.mirror.hashicorp.services/${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--latest-version "${{ env.CONSUL_LATEST_VERSION }}"
ls -lrt
env:
# this is needed because of incompatibility between RYUK container and GHA

0
test/integration/consul-container/libs/service/assets/Dockerfile-consul-envoy → test/integration/consul-container/assets/Dockerfile-consul-envoy

0
test/integration/consul-container/libs/service/assets/tproxy-startup.sh → test/integration/consul-container/assets/tproxy-startup.sh

56
test/integration/consul-container/go.mod

@ -5,7 +5,7 @@ go 1.20
require (
fortio.org/fortio v1.54.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/docker/docker v20.10.22+incompatible
github.com/docker/docker v23.0.6+incompatible
github.com/docker/go-connections v0.4.0
github.com/hashicorp/consul/api v1.20.0
github.com/hashicorp/consul/envoyextensions v0.1.2
@ -19,11 +19,11 @@ require (
github.com/mitchellh/copystructure v1.2.0
github.com/otiai10/copy v1.10.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.2
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569
github.com/testcontainers/testcontainers-go v0.15.0
golang.org/x/mod v0.8.0
google.golang.org/grpc v1.53.0
github.com/testcontainers/testcontainers-go v0.20.1
golang.org/x/mod v0.10.0
google.golang.org/grpc v1.55.0
)
require (
@ -32,21 +32,19 @@ require (
fortio.org/sets v1.0.2 // indirect
fortio.org/version v1.0.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/hcsshim v0.9.7 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.19 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195 // indirect
github.com/containerd/containerd v1.7.1 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/envoyproxy/go-control-plane v0.10.3 // indirect
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect
github.com/envoyproxy/go-control-plane v0.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v0.10.0 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/uuid v1.3.0 // indirect
@ -58,33 +56,35 @@ require (
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/memberlist v0.5.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/itchyny/timefmt-go v0.1.4 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opencensus.io v0.23.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
google.golang.org/protobuf v1.28.1 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
)
replace github.com/hashicorp/consul/api => ../../../api

1065
test/integration/consul-container/go.sum

File diff suppressed because it is too large Load Diff

3
test/integration/consul-container/libs/cluster/app.go

@ -62,8 +62,9 @@ func LaunchContainerOnNode(
ContainerRequest: req,
Started: true,
})
fmt.Printf("creating container with image: %s(%s)\n", req.Name, req.Image)
if err != nil {
return nil, fmt.Errorf("creating container: %w", err)
return nil, fmt.Errorf("creating container: %s(%s), %w", req.Name, req.Image, err)
}
deferClean.Add(func() {
_ = container.Terminate(ctx)

53
test/integration/consul-container/libs/service/common.go

@ -4,12 +4,8 @@
package service
import (
"archive/tar"
"bytes"
_ "embed"
"os"
"github.com/testcontainers/testcontainers-go"
)
const (
@ -20,55 +16,6 @@ const (
hashicorpDockerProxy = "docker.mirror.hashicorp.services"
)
//go:embed assets/Dockerfile-consul-envoy
var consulEnvoyDockerfile []byte
//go:embed assets/tproxy-startup.sh
var tproxyStartupScript []byte
// getDevContainerDockerfile returns the necessary context to build a combined consul and
// envoy image for running "consul connect envoy ..."
func getDevContainerDockerfile() (testcontainers.FromDockerfile, error) {
var buf bytes.Buffer
tw := tar.NewWriter(&buf)
hdr := &tar.Header{
Name: "Dockerfile",
Mode: 0600,
Size: int64(len(consulEnvoyDockerfile)),
}
if err := tw.WriteHeader(hdr); err != nil {
return testcontainers.FromDockerfile{}, err
}
if _, err := tw.Write(consulEnvoyDockerfile); err != nil {
return testcontainers.FromDockerfile{}, err
}
hdr = &tar.Header{
Name: "tproxy-startup.sh",
Mode: 0600,
Size: int64(len(tproxyStartupScript)),
}
if err := tw.WriteHeader(hdr); err != nil {
return testcontainers.FromDockerfile{}, err
}
if _, err := tw.Write(tproxyStartupScript); err != nil {
return testcontainers.FromDockerfile{}, err
}
if err := tw.Close(); err != nil {
return testcontainers.FromDockerfile{}, err
}
reader := bytes.NewReader(buf.Bytes())
fromDockerfile := testcontainers.FromDockerfile{
ContextArchive: reader,
}
return fromDockerfile, nil
}
func getEnvoyVersion() string {
if version, ok := os.LookupEnv(envoyEnvKey); ok && version != "" {
return version

27
test/integration/consul-container/libs/service/connect.go

@ -167,29 +167,24 @@ func NewConnectService(ctx context.Context, sidecarCfg SidecarConfig, serviceBin
namePrefix := fmt.Sprintf("%s-service-connect-%s", node.GetDatacenter(), sidecarCfg.Name)
containerName := utils.RandName(namePrefix)
envoyVersion := getEnvoyVersion()
agentConfig := node.GetConfig()
buildargs := map[string]*string{
"ENVOY_VERSION": utils.StringToPointer(envoyVersion),
"CONSUL_IMAGE": utils.StringToPointer(agentConfig.DockerImage()),
}
dockerfileCtx, err := getDevContainerDockerfile()
if err != nil {
return nil, err
}
dockerfileCtx.BuildArgs = buildargs
internalAdminPort, err := node.ClaimAdminPort()
if err != nil {
return nil, err
}
fmt.Println("agent image name", agentConfig.DockerImage())
imageVersion := ""
if strings.Contains(agentConfig.DockerImage(), "local") {
imageVersion = "target-version"
} else {
imageVersion = "latest-version"
}
req := testcontainers.ContainerRequest{
FromDockerfile: dockerfileCtx,
WaitingFor: wait.ForLog("").WithStartupTimeout(10 * time.Second),
AutoRemove: false,
Name: containerName,
Image: fmt.Sprintf("consul-envoy:%s", imageVersion),
WaitingFor: wait.ForLog("").WithStartupTimeout(100 * time.Second),
AutoRemove: false,
Name: containerName,
Cmd: []string{
"consul", "connect", "envoy",
"-sidecar-for", sidecarCfg.ServiceID,

2
test/integration/consul-container/libs/service/examples.go

@ -153,7 +153,7 @@ func NewExampleService(ctx context.Context, name string, httpPort int, grpcPort
req := testcontainers.ContainerRequest{
Image: hashicorpDockerProxy + "/fortio/fortio",
WaitingFor: wait.ForLog("").WithStartupTimeout(10 * time.Second),
WaitingFor: wait.ForLog("").WithStartupTimeout(60 * time.Second),
AutoRemove: false,
Name: containerName,
Cmd: command,

32
test/integration/consul-container/libs/service/gateway.go

@ -9,6 +9,7 @@ import (
"io"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/testcontainers/testcontainers-go"
@ -161,19 +162,7 @@ func NewGatewayServiceReg(ctx context.Context, gwCfg GatewayConfig, node libclus
namePrefix := fmt.Sprintf("%s-service-gateway-%s", node.GetDatacenter(), gwCfg.Name)
containerName := utils.RandName(namePrefix)
envoyVersion := getEnvoyVersion()
agentConfig := node.GetConfig()
buildargs := map[string]*string{
"ENVOY_VERSION": utils.StringToPointer(envoyVersion),
"CONSUL_IMAGE": utils.StringToPointer(agentConfig.DockerImage()),
}
dockerfileCtx, err := getDevContainerDockerfile()
if err != nil {
return nil, err
}
dockerfileCtx.BuildArgs = buildargs
adminPort, err := node.ClaimAdminPort()
if err != nil {
return nil, err
@ -194,13 +183,20 @@ func NewGatewayServiceReg(ctx context.Context, gwCfg GatewayConfig, node libclus
"--log-level", envoyLogLevel,
}
fmt.Println("agent image name", agentConfig.DockerImage())
imageVersion := ""
if strings.Contains(agentConfig.DockerImage(), "local") {
imageVersion = "target-version"
} else {
imageVersion = "latest-version"
}
req := testcontainers.ContainerRequest{
FromDockerfile: dockerfileCtx,
WaitingFor: wait.ForLog("").WithStartupTimeout(10 * time.Second),
AutoRemove: false,
Name: containerName,
Env: make(map[string]string),
Cmd: append(cmd, envoyArgs...),
Image: fmt.Sprintf("consul-envoy:%s", imageVersion),
WaitingFor: wait.ForLog("").WithStartupTimeout(100 * time.Second),
AutoRemove: false,
Name: containerName,
Env: make(map[string]string),
Cmd: append(cmd, envoyArgs...),
}
nodeInfo := node.GetInfo()

0
test/integration/consul-container/test/upgrade/basic_test.go → test/integration/consul-container/test/upgrade/basic/basic_test.go

0
test/integration/consul-container/test/upgrade/fullstopupgrade_test.go → test/integration/consul-container/test/upgrade/basic/fullstopupgrade_test.go

0
test/integration/consul-container/test/upgrade/healthcheck_test.go → test/integration/consul-container/test/upgrade/basic/healthcheck_test.go

6
test/integration/consul-container/test/upgrade/l7_traffic_management/resolver_default_subset_test.go

@ -21,7 +21,7 @@ import (
// Test resolver directs traffic to default subset
// - Create 2 additional static-server instances: one in V1 subset and the other in V2 subset
// - resolver directs traffic to the default subset, which is V2.
func TestTrafficManagement_ResolveDefaultSubset(t *testing.T) {
func TestTrafficManagement_ResolverDefaultSubset(t *testing.T) {
t.Parallel()
cluster, staticServerProxy, staticClientProxy := setup(t)
@ -113,6 +113,8 @@ func TestTrafficManagement_ResolveDefaultSubset(t *testing.T) {
// - Create one addtional static-server with checks and V1 subset
// - resolver directs traffic to "test" service
func TestTrafficManagement_ResolverDefaultOnlyPassing(t *testing.T) {
t.Parallel()
cluster, staticServerProxy, staticClientProxy := setup(t)
node := cluster.Agents[0]
@ -211,6 +213,8 @@ func TestTrafficManagement_ResolverDefaultOnlyPassing(t *testing.T) {
// - Create 3 static-server-2 server instances: one in V1, one in V2, one without any version
// - service2Resolver directs traffic to static-server-2-v2V
func TestTrafficManagement_ResolverSubsetRedirect(t *testing.T) {
t.Parallel()
cluster, staticServerProxy, staticClientProxy := setup(t)
node := cluster.Agents[0]

0
test/integration/consul-container/test/upgrade/peering_control_plane_mgw_test.go → test/integration/consul-container/test/upgrade/peering/peering_control_plane_mgw_test.go

0
test/integration/consul-container/test/upgrade/peering_http_test.go → test/integration/consul-container/test/upgrade/peering/peering_http_test.go

Loading…
Cancel
Save