-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
print & log port bind failures, dns-related test coverage, test impro…
…vements (#239) * exercise puma-dev dns lookup is there really no way to specify test-only dependencies? move unexported methods to the bottom first pass at catching errors from dns port bind refactor to use tomb over chan expose errors in listening for TLS and DNS remove default error handling. bail if we didn't get a good address remove "debug" messaging about not regenerating keypair nevermind -- most folks don't run this interactively, and its handy to have it in the log for now, just skip dns tests outside darwin fix compile error * test tcp and udp connection to dns * extract darwin-only DNS test skip high_sierra for now. fsevents are broken loop over tcp, udp go mod tidy map[string](func() interface{}) is awesome. refactor stdout capture to use return function instead of passed function call forgot one see if waiting for the shutdown to finish helps assert serve doesn't serve an error either only try to shutdown the server if we have a handle to it defer shutdown and fail if unable to shutdown remove timeout. we'll see if that fails. remove error stubs use constructor to init dns servers to avoid race remove retry print missed one shorten timeout, add comments to clarify intent of retries * only run one background puma-dev per platform; os.Exit will shutdown only run one server per set of server test scenarios, so os.Exit will handle the cleanup put shutdown back inside main -- it calls os.Exit() which borks testing pull out additional state into each platform spec ensure we run things on completely non-standard ports missed an import * alphabetize main test methods, pass flags to puma-dev boot * remove unused import * remove another unused import * ensure we don't fail to boot the server, add additional dns tests * ensure we set flags _before_ we read *fHTTPPort /facepalm * trying to debug a really rare flake.
- Loading branch information
1 parent
440d774
commit b98aa54
Showing
8 changed files
with
293 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ workflows: | |
version: 2 | ||
test: | ||
jobs: | ||
- test_high_sierra | ||
# - test_high_sierra | ||
- test_mojave | ||
- test_catalina | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net" | ||
"testing" | ||
|
||
"github.com/puma/puma-dev/homedir" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMainPumaDev_Darwin(t *testing.T) { | ||
appLinkDir := homedir.MustExpand("~/.gotest-macos-puma-dev") | ||
|
||
defer linkAllTestApps(t, appLinkDir)() | ||
|
||
serveErr := configureAndBootPumaDevServer(t, map[string]string{ | ||
"d": "test:puma", | ||
"dir": appLinkDir, | ||
"dns-port": "65053", | ||
"http-port": "65080", | ||
"https-port": "65443", | ||
}) | ||
|
||
assert.NoError(t, serveErr) | ||
|
||
runPlatformAgnosticTestScenarios(t) | ||
|
||
t.Run("resolve dns", func(t *testing.T) { | ||
PumaDevDNSDialer := func(ctx context.Context, network, address string) (net.Conn, error) { | ||
dnsAddress := fmt.Sprintf("127.0.0.1:%d", *fDNSPort) | ||
d := net.Dialer{} | ||
return d.DialContext(ctx, "udp", dnsAddress) | ||
} | ||
|
||
r := net.Resolver{ | ||
PreferGo: true, | ||
Dial: PumaDevDNSDialer, | ||
} | ||
|
||
ctx := context.Background() | ||
ips, err := r.LookupIPAddr(ctx, "foo.test") | ||
assert.NoError(t, err) | ||
assert.Equal(t, net.ParseIP("127.0.0.1").To4(), ips[0].IP.To4()) | ||
|
||
ips, err = r.LookupIPAddr(ctx, "foo.puma") | ||
assert.NoError(t, err) | ||
assert.Equal(t, net.ParseIP("127.0.0.1").To4(), ips[0].IP.To4()) | ||
|
||
_, err = r.LookupIPAddr(ctx, "foo.tlddoesnotexist") | ||
assert.Error(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/puma/puma-dev/homedir" | ||
) | ||
|
||
func TestMainPumaDev_Linux(t *testing.T) { | ||
appLinkDir := homedir.MustExpand("~/.gotest-linux-puma-dev") | ||
|
||
defer linkAllTestApps(t, appLinkDir)() | ||
|
||
configureAndBootPumaDevServer(t, map[string]string{ | ||
"dir": appLinkDir, | ||
"http-port": "65080", | ||
"https-port": "65443", | ||
}) | ||
|
||
runPlatformAgnosticTestScenarios(t) | ||
} |
Oops, something went wrong.