Skip to content

Commit

Permalink
tests: client: enable a batch of integration tests for wcow
Browse files Browse the repository at this point in the history
WIP

- [x] `testStdinClosed`
- [x] `testHostnameLookup`
- [x] `testHostnameSpecifying`

Addressing #4485

Signed-off-by: Anthony Nandaa <[email protected]>
  • Loading branch information
profnandaa committed Dec 2, 2024
1 parent 38a47db commit e8ed7b2
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ func testExportBusyboxLocal(t *testing.T, sb integration.Sandbox) {
}

func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
if sb.Rootless() { // bridge is not used by default, even with detach-netns
t.SkipNow()
}
Expand All @@ -593,7 +592,12 @@ func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
require.NoError(t, err)
defer c.Close()

st := llb.Image("busybox:latest").Run(llb.Shlex(`sh -c "ping -c 1 $(hostname)"`))
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
cmdStr := integration.UnixOrWindows(
`sh -c "ping -c 1 $(hostname)"`,
"cmd /C ping -n 1 %%COMPUTERNAME%%",
)
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))

def, err := st.Marshal(sb.Context())
require.NoError(t, err)
Expand All @@ -604,7 +608,6 @@ func testHostnameLookup(t *testing.T, sb integration.Sandbox) {

// moby/buildkit#1301
func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
if sb.Rootless() { // bridge is not used by default, even with detach-netns
t.SkipNow()
}
Expand All @@ -614,9 +617,21 @@ func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
defer c.Close()

hostname := "testtest"
st := llb.Image("busybox:latest").With(llb.Hostname(hostname)).
Run(llb.Shlexf("sh -c 'echo $HOSTNAME | grep %s'", hostname)).
Run(llb.Shlexf("sh -c 'echo $(hostname) | grep %s'", hostname))
// NOTE: Windows capitalizes the hostname hence
// case insensitive findstr (findstr /I)
// testtest --> TESTTEST
cmdStr1 := integration.UnixOrWindows(
"sh -c 'echo $HOSTNAME | grep %s'",
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
)
cmdStr2 := integration.UnixOrWindows(
"sh -c 'echo $(hostname) | grep %s'",
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
)
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
st := llb.Image(imgName).With(llb.Hostname(hostname)).
Run(llb.Shlexf(cmdStr1, hostname)).
Run(llb.Shlexf(cmdStr2, hostname))

def, err := st.Marshal(sb.Context())
require.NoError(t, err)
Expand All @@ -629,12 +644,13 @@ func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {

// moby/buildkit#614
func testStdinClosed(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()

st := llb.Image("busybox:latest").Run(llb.Shlex("cat"))
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
cmdStr := integration.UnixOrWindows("cat", "cmd /C more")
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))

def, err := st.Marshal(sb.Context())
require.NoError(t, err)
Expand Down Expand Up @@ -1186,7 +1202,6 @@ func testSecurityModeErrors(t *testing.T, sb integration.Sandbox) {
}

func testFrontendImageNaming(t *testing.T, sb integration.Sandbox) {
requiresLinux(t)
c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()
Expand Down

0 comments on commit e8ed7b2

Please sign in to comment.