Skip to content

Commit

Permalink
Skip TCP domains when finding default domain in integration tests
Browse files Browse the repository at this point in the history
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 <rmitchell@pivotal.io>
  • Loading branch information
reidmit committed Jun 17, 2020
1 parent 26e9718 commit b67291e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions integration/helpers/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b67291e

Please sign in to comment.