add integration tests for DNS proxy

Signed-off-by: Bohan Chen <bochen@pivotal.io>
Co-authored-by: Taylor Silva <tsilva@pivotal.io>
This commit is contained in:
Bohan Chen 2021-04-28 16:51:26 -04:00
parent 40b1f73ce2
commit 5ba052e7cb
6 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,47 @@
package main
import (
"testing"
"github.com/concourse/concourse/integration/internal/dctest"
"github.com/concourse/concourse/integration/internal/flytest"
)
func TestDNSProxyyEnabled(t *testing.T) {
t.Parallel()
dc := dctest.Init(t, "../docker-compose.yml", "overrides/enable_dns_proxy.yml")
t.Run("deploy with DNS proxy enabled", func(t *testing.T) {
dc.Run(t, "up", "-d")
})
fly := flytest.Init(t, dc)
fly.WithEnv("EXPECTED_EXIT_CODE=0").Run(t, "execute", "-c", "tasks/assert_web_is_reachable.yml")
}
func TestDNSProxyyDisabled(t *testing.T) {
t.Parallel()
dc := dctest.Init(t, "../docker-compose.yml", "overrides/disable_dns_proxy.yml")
t.Run("deploy with DNS proxy disabled", func(t *testing.T) {
dc.Run(t, "up", "-d")
})
fly := flytest.Init(t, dc)
fly.WithEnv("EXPECTED_EXIT_CODE=1").Run(t, "execute", "-c", "tasks/assert_web_is_reachable.yml")
}
func TestExtraDNSServersAreAdded(t *testing.T) {
t.Parallel()
dc := dctest.Init(t, "../docker-compose.yml", "overrides/add_extra_dns_servers.yml")
t.Run("deploy with extra DNS servers", func(t *testing.T) {
dc.Run(t, "up", "-d")
})
fly := flytest.Init(t, dc)
fly.WithEnv("EXTRA_SERVER=1.1.1.1").Run(t, "execute", "-c", "tasks/assert_extra_dns_servers.yml")
}

View File

@ -0,0 +1,6 @@
version: '3'
services:
worker:
environment:
CONCOURSE_CONTAINERD_DNS_SERVER: "1.1.1.1"

View File

@ -0,0 +1,6 @@
version: '3'
services:
worker:
environment:
CONCOURSE_CONTAINERD_DNS_PROXY_ENABLE: "false"

View File

@ -0,0 +1,6 @@
version: '3'
services:
worker:
environment:
CONCOURSE_CONTAINERD_DNS_PROXY_ENABLE: "true"

View File

@ -0,0 +1,17 @@
platform: linux
image_resource:
type: mock
source: {mirror_self: true}
params:
EXTRA_SERVER:
run:
path: sh
args:
- -c
- |
set -ex
grep $EXTRA_SERVER /etc/resolv.conf

View File

@ -0,0 +1,20 @@
platform: linux
image_resource:
type: mock
source: {mirror_self: true}
params:
EXPECTED_EXIT_CODE:
run:
path: sh
args:
- -c
- |
set -x
nslookup web
if [ $? -ne $EXPECTED_EXIT_CODE ]; then
exit 1
fi