blob: fefff074631c91da623c1e7623426a3e39a2af64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
BeforeAll {
. $PSScriptRoot/../lib/lib.ps1
}
Describe "Docker (native)" {
BeforeAll {
$distro = Install-Distro
try {
$distro.InstallConfig("$PSScriptRoot/docker-native.nix")
}
catch {
$distro.Launch("sudo journalctl --no-pager -u docker.service")
throw $_
}
}
It "should be possible to run a docker container" {
$distro.Launch("docker run --rm -it hello-world")
$LASTEXITCODE | Should -Be 0
}
It "should still be possible to run a docker container after a restart" {
$distro.Shutdown()
$distro.Launch("docker run --rm -it hello-world")
$LASTEXITCODE | Should -Be 0
}
It "should be possible to connect to the internet from a container" {
$distro.Launch("docker run --rm -it alpine wget -qO- http://www.msftconnecttest.com/connecttest.txt") | Select-Object -Last 1 | Should -BeExactly "Microsoft Connect Test"
# docker exec -it $distro.id /nix/nixos-wsl/entrypoint -c "docker run --rm -it alpine wget -qO- http://www.msftconnecttest.com/connecttest.txt" | Select-Object -Last 1 | Should -BeExactly "Microsoft Connect Test"
$LASTEXITCODE | Should -Be 0
}
It "should be possible to mount a volume from the host" {
$teststring = [guid]::NewGuid().ToString()
$testdir = $distro.Launch("mktemp -d") | Select-Object -Last 1
$testfilename = "testfile"
$testfile = "${testdir}/${testfilename}"
$distro.Launch("echo $teststring > $testfile")
$distro.Launch("docker run --rm -it -v ${testdir}:/mnt alpine cat /mnt/${testfilename}") | Select-Object -Last 1 | Should -BeExactly $teststring
$LASTEXITCODE | Should -Be 0
}
AfterAll {
$distro.Uninstall()
}
}
|