Skip to content

Commit

Permalink
[testing] Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsturtevant committed Nov 10, 2021
1 parent fff5d9e commit 9e869e4
Showing 3 changed files with 96 additions and 12 deletions.
41 changes: 29 additions & 12 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
freebsd_instance:
image_family: freebsd-13-0
#freebsd_instance:
# image_family: freebsd-13-0
#
#task:
# name: test-freebsd-amd64
# env:
# NERDCTL_RUN_ARGS: --net none knast/freebsd:13-STABLE echo "Nerdctl is up and running."
# install_script:
# - pkg install -y go containerd runj
# - daemon -o containerd.out containerd
# test_script:
# - go test -v ./pkg/...
# - cd cmd/nerdctl
# - sudo go run . run $NERDCTL_RUN_ARGS | grep running

task:
name: test-freebsd-amd64
docker_builder:
name: windows
platform: windows
os_version: 2019
env:
NERDCTL_RUN_ARGS: --net none knast/freebsd:13-STABLE echo "Nerdctl is up and running."
install_script:
- pkg install -y go containerd runj
- daemon -o containerd.out containerd
test_script:
- go test -v ./pkg/...
- cd cmd/nerdctl
- sudo go run . run $NERDCTL_RUN_ARGS | grep running
CGO_ENABLED: 0
GOTMPDIR: C:\\Windows\\TEMP\\cirrus-ci-build\\gotmp
TEMP: C:\\Windows\\TEMP\\cirrus-ci-build\\tempfiles
build_script:
- mkdir %GOTMPDIR%
- mkdir %TEMP%
- powershell hack/configure-windows-ci.ps1
- refreshenv
- go install .\cmd\nerdctl\
- mkdir "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\"
- go test -v -run ^\QTestRunEnvFile\E$ ./cmd/...
60 changes: 60 additions & 0 deletions hack/configure-windows-ci.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
$ErrorActionPreference = "Stop"

#install golang
choco install --limitoutput --no-progress -y golang
refreshenv

#install containerd
$Version="1.5.7"
curl.exe -L https://github.com/containerd/containerd/releases/download/v$Version/containerd-$Version-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz
tar xvf containerd-windows-amd64.tar.gz
mkdir -force "$Env:ProgramFiles\containerd"
mv ./bin/* "$Env:ProgramFiles\containerd"

& $Env:ProgramFiles\containerd\containerd.exe config default | Out-File "$Env:ProgramFiles\containerd\config.toml" -Encoding ascii
& $Env:ProgramFiles\containerd\containerd.exe --register-service
Start-Service containerd

#configure cni
mkdir -force "$Env:ProgramFiles\containerd\cni\bin"
mkdir -force "$Env:ProgramFiles\containerd\cni\conf"
curl.exe -LO https://github.com/microsoft/windows-container-networking/releases/download/v0.2.0/windows-container-networking-cni-amd64-v0.2.0.zip
Expand-Archive windows-container-networking-cni-amd64-v0.2.0.zip -DestinationPath "$Env:ProgramFiles\containerd\cni\bin" -Force

curl.exe -LO https://raw.githubusercontent.com/microsoft/SDN/master/Kubernetes/windows/hns.psm1
ipmo ./hns.psm1

# cirrus already has nat net work configured for docker. We can re-use that for testing
$sn=(get-hnsnetwork | ? Name -Like "nat" | select -ExpandProperty subnets)
$subnet=$sn.AddressPrefix
$gateway=$sn.GatewayAddress
@"
{
"cniVersion": "0.2.0",
"name": "nat",
"type": "nat",
"master": "Ethernet",
"ipam": {
"subnet": "$subnet",
"routes": [
{
"gateway": "$gateway"
}
]
},
"capabilities": {
"portMappings": true,
"dns": true
}
}
"@ | Set-Content "$Env:ProgramFiles\containerd\cni\conf\0-containerd-nat.conf" -Force

echo "configuration complete! Printing configuration..."
echo "Service:"
get-service containerd
echo "cni configuraiton"
cat "$Env:ProgramFiles\containerd\cni\conf\0-containerd-nat.conf"
ls "$Env:ProgramFiles\containerd\cni\bin"
echo "containerd install"
ls "$Env:ProgramFiles\containerd\"
& "$Env:ProgramFiles\containerd\containerd.exe" --version
7 changes: 7 additions & 0 deletions pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
"io"
"os"
"os/exec"
"runtime"
"strings"
"testing"
"time"
@@ -399,6 +400,12 @@ func NewBase(t *testing.T) *Base {
}

func mirrorOf(s string) string {
if runtime.GOOS == "windows" {
// use gcr.io/k8s-staging-e2e-test-images/busybox:1.29-2-windows-amd64-ltsc2022 locally on windows 11
// https://github.com/microsoft/Windows-Containers/issues/179
return "gcr.io/k8s-staging-e2e-test-images/busybox:1.29-2"
}

// plain mirror, NOT stargz-converted images
return fmt.Sprintf("ghcr.io/stargz-containers/%s-org", s)
}

0 comments on commit 9e869e4

Please sign in to comment.