Skip to content

Commit

Permalink
Fix HPC tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kirtana Ashok <[email protected]>
  • Loading branch information
kiashok committed Jul 18, 2024
1 parent c28c0b2 commit a2db45f
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 77 deletions.
23 changes: 15 additions & 8 deletions test/cri-containerd/jobcontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,13 @@ func Test_RunContainer_JobContainer_Environment(t *testing.T) {
client := newTestRuntimeClient(t)

type config struct {
name string
containerName string
sandboxImage string
containerImage string
env []*runtime.KeyValue
exec []string
name string
containerName string
sandboxImage string
containerImage string
env []*runtime.KeyValue
exec []string
expectedExecResult string
}

tests := []config{
Expand All @@ -544,7 +545,8 @@ func Test_RunContainer_JobContainer_Environment(t *testing.T) {
Key: "PATH", Value: "C:\\Windows\\system32;C:\\Windows",
},
},
exec: []string{"cmd", "/c", "IF", "%PATH%", "==", "C:\\Windows\\system32;C:\\Windows", "( exit 0 )", "ELSE", "(exit -1)"},
exec: []string{"cmd", "/c", "echo %PATH%"},
expectedExecResult: "C:\\Windows\\system32;C:\\Windows;C:\\hpc\\;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\Wbem",
},
{
name: "JobContainer_VolumeMount_WithMountPoint",
Expand All @@ -556,7 +558,8 @@ func Test_RunContainer_JobContainer_Environment(t *testing.T) {
Key: "PATH", Value: "%CONTAINER_SANDBOX_MOUNT_POINT%\\apps\\vim\\;C:\\Windows\\system32;C:\\Windows",
},
},
exec: []string{"cmd", "/c", "IF", "%PATH%", "==", "%CONTAINER_SANDBOX_MOUNT_POINT%\\apps\\vim\\;C:\\Windows\\system32;C:\\Windows", "( exit -1 )", "ELSE", "(exit 0)"},
exec: []string{"cmd", "/c", "echo %PATH%"},
expectedExecResult: `C:\hpc\apps\vim\;C:\Windows\system32;C:\Windows;C:\hpc\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\Wbem`,
},
}

Expand Down Expand Up @@ -589,6 +592,10 @@ func Test_RunContainer_JobContainer_Environment(t *testing.T) {
if r.ExitCode != 0 {
t.Fatalf("failed with exit code %d checking for job container mount: %s", r.ExitCode, string(r.Stderr))
}
stdout := strings.TrimSpace(string(r.Stdout))
if stdout != test.expectedExecResult {
t.Fatalf("PATH does not match. Expected: %v Actual: %v", test.expectedExecResult, stdout)
}
})
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/cri-containerd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ const (
imageWindowsArgsEscaped = "cplatpublic.azurecr.io/argsescaped:latest"
imageWindowsTimezone = "cplatpublic.azurecr.io/timezone:latest"

imageJobContainerHNS = "cplatpublic.azurecr.io/jobcontainer_hns:latest"
imageJobContainerETW = "cplatpublic.azurecr.io/jobcontainer_etw:latest"
imageJobContainerVHD = "cplatpublic.azurecr.io/jobcontainer_vhd:latest"
imageJobContainerCmdline = "cplatpublic.azurecr.io/jobcontainer_cmdline:latest"
imageJobContainerWorkDir = "cplatpublic.azurecr.io/jobcontainer_workdir:latest"
imageJobContainerHNS = "cplatpublic.azurecr.io/hpc_hns:latest"
imageJobContainerETW = "cplatpublic.azurecr.io/hpc_etw:latest"
imageJobContainerVHD = "cplatpublic.azurecr.io/hpc_vhd:latest"
imageJobContainerCmdline = "cplatpublic.azurecr.io/hpc_cmdline:latest"
imageJobContainerWorkDir = "cplatpublic.azurecr.io/hpc_workdir:latest"

gracefulTerminationServercore = "cplatpublic.azurecr.io/servercore-gracefultermination-repro:latest"
gracefulTerminationNanoserver = "cplatpublic.azurecr.io/nanoserver-gracefultermination-repro:latest"
Expand Down
5 changes: 5 additions & 0 deletions test/cri-containerd/test-images/hpc_cmdline/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022

USER containeradministrator

COPY ./cmdline.exe /
6 changes: 6 additions & 0 deletions test/cri-containerd/test-images/hpc_etw/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022

USER containeradministrator

COPY ./etw.exe /
COPY test.wprp /
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ func main() {
os.Exit(1)
}

path := filepath.Join(filepath.Dir(os.Args[0]), "Test.wprp")
path := filepath.Join(filepath.Dir(os.Args[0]), "test.wprp")
if _, err := os.Stat(path); os.IsNotExist(err) {
log.Fatalf("failed to find wprp file %v: %s", path, err)
}

if err := exec.Command("wpr", "-start", path).Run(); err != nil {
log.Fatalf("failed to wpr start: %s", err)
}
Expand Down
2 changes: 2 additions & 0 deletions test/cri-containerd/test-images/hpc_hns/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY ./hns.exe /
2 changes: 2 additions & 0 deletions test/cri-containerd/test-images/hpc_vhd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY ./vhd.exe /
2 changes: 2 additions & 0 deletions test/cri-containerd/test-images/hpc_workdir/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY ./hpc_workdir.exe /
11 changes: 0 additions & 11 deletions test/cri-containerd/test-images/jobcontainer_cmdline/dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions test/cri-containerd/test-images/jobcontainer_createvhd/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions test/cri-containerd/test-images/jobcontainer_etw/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions test/cri-containerd/test-images/jobcontainer_hns/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions test/cri-containerd/test-images/jobcontainer_workdir/Dockerfile

This file was deleted.

0 comments on commit a2db45f

Please sign in to comment.