From b67291ee42aae13bb6542a6af43084ba6024afb8 Mon Sep 17 00:00:00 2001 From: Reid Mitchell Date: Tue, 16 Jun 2020 17:28:23 -0700 Subject: [PATCH] Skip TCP domains when finding default domain in integration tests We recently began seeing failures when a TCP route (a route using a TCP domain) was being used unexpectedly. I believe it is because this DefaultSharedDomain helper was not excluding domains with protocol "tcp". Now, we exclude them, just like we do for internal domains, so that the "default domain" it finds will never be a TCP domain. Authored-by: Reid Mitchell --- integration/helpers/domains.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/integration/helpers/domains.go b/integration/helpers/domains.go index a24adea724c..c6aa125c263 100644 --- a/integration/helpers/domains.go +++ b/integration/helpers/domains.go @@ -42,18 +42,31 @@ func DefaultSharedDomain() string { session := CF("domains") Eventually(session).Should(Exit(0)) - regex := regexp.MustCompile(`(.+?)\s+shared.*`) - output := strings.Split(string(session.Out.Contents()), "\n") for _, line := range output { - if line != "" && !strings.HasPrefix(line, "integration-") { - matches := regex.FindStringSubmatch(line) - if len(matches) == 2 && !strings.Contains(matches[0], "true") && !strings.Contains(matches[0], "internal") { - foundDefaultDomain = matches[1] - break - } + if line == "" { + // Skip empty lines + continue + } + + if strings.HasPrefix(line, "integration-") { + // Skip domains created as part of integration tests + continue + } + + if strings.HasSuffix(line, "tcp") { + // Skip domains with protocol "tcp" + continue + } + + regex := regexp.MustCompile(`(.+?)\s+shared.*`) + matches := regex.FindStringSubmatch(line) + if len(matches) == 2 && !strings.Contains(matches[0], "true") && !strings.Contains(matches[0], "internal") { + foundDefaultDomain = matches[1] + break } } + Expect(foundDefaultDomain).ToNot(BeEmpty()) } return foundDefaultDomain