Skip to content

Commit 334e747

Browse files
authored
Merge pull request #5165 from adelina-t/azure_ci_workflow
Add CI periodic Windows Jobs.
2 parents c8cbf79 + 77285e3 commit 334e747

4 files changed

Lines changed: 246 additions & 1 deletion

File tree

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Workflow intended to periodically test containerd integration tests
2+
3+
name: win-periodic-integration
4+
5+
on:
6+
schedule:
7+
- cron: "0 1 * * *"
8+
9+
env:
10+
AZURE_DEFAULT_LOCATION: westeurope
11+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUB_ID }}
12+
AZURE_DEFAULT_VM_SIZE: Standard_D2s_v3
13+
PASSWORD: Passw0rdAdmin # temp for testing, will be generated
14+
DEFAULT_ADMIN_USERNAME: azureuser
15+
SSH_OPTS: "-o ServerAliveInterval=20 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
16+
REMOTE_VM_BIN_PATH: "c:\\containerd\\bin"
17+
18+
jobs:
19+
winIntegration:
20+
strategy:
21+
matrix:
22+
win_ver: [ltsc2019, sac2004]
23+
include:
24+
- win_ver: sac2004
25+
AZURE_IMG: "MicrosoftWindowsServer:WindowsServer:datacenter-core-2004-with-containers-smalldisk:19041.928.2104150521"
26+
AZURE_RESOURCE_GROUP: ctrd-integration-sac2004-${{ github.run_id }}
27+
GOOGLE_BUCKET: "gs://containerd-integration/logs/windows-sac2004/"
28+
- win_ver: ltsc2019
29+
AZURE_IMG: "MicrosoftWindowsServer:WindowsServer:2019-Datacenter-with-Containers-smalldisk:17763.1935.2105080716"
30+
AZURE_RESOURCE_GROUP: ctrd-integration-ltsc2019-${{ github.run_id }}
31+
GOOGLE_BUCKET: "gs://containerd-integration/logs/windows-ltsc2019/"
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
36+
- name: Install required packages
37+
run: |
38+
sudo apt-get install xmlstarlet -y
39+
40+
- name: PrepareArtifacts
41+
run: |
42+
STARTED_TIME=$(date +%s)
43+
LOGS_DIR=$HOME/$STARTED_TIME
44+
echo "STARTED_TIME=$STARTED_TIME" >> $GITHUB_ENV
45+
echo "LOGS_DIR=$LOGS_DIR" >> $GITHUB_ENV
46+
mkdir -p $LOGS_DIR/artifacts
47+
48+
jq -n --arg node temp --arg timestamp $STARTED_TIME '$timestamp|tonumber|{timestamp:.,$node}' > $LOGS_DIR/started.json
49+
50+
- name: Generate ssh key pair
51+
run: |
52+
mkdir -p $HOME/.ssh/
53+
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f $HOME/.ssh/id_rsa -q -N ""
54+
echo "SSH_PUB_KEY=$(cat ~/.ssh/id_rsa.pub)" >> $GITHUB_ENV
55+
56+
- name: AZLogin
57+
uses: azure/login@v1
58+
with:
59+
creds: ${{ secrets.AZURE_CREDS }}
60+
61+
- name: AZResourceGroupCreate
62+
uses: azure/CLI@v1
63+
with:
64+
azcliversion: latest
65+
inlinescript: |
66+
az group create -n ${{ matrix.AZURE_RESOURCE_GROUP }} -l ${{ env.AZURE_DEFAULT_LOCATION }}
67+
68+
- name: AZTestVMCreate
69+
uses: azure/CLI@v1
70+
with:
71+
azcliversion: latest
72+
inlinescript: |
73+
az vm create -n winTestVM --admin-username ${{ env.DEFAULT_ADMIN_USERNAME }} --admin-password ${{ env.PASSWORD }} --image ${{ matrix.AZURE_IMG }} -g ${{ matrix.AZURE_RESOURCE_GROUP }} --nsg-rule SSH --size ${{ env.AZURE_DEFAULT_VM_SIZE }}
74+
75+
- name: GetAZVMPublicIP
76+
uses: azure/CLI@v1
77+
with:
78+
azcliversion: latest
79+
inlinescript: |
80+
echo "VM_PUB_IP=$(az network public-ip list -g ${{ matrix.AZURE_RESOURCE_GROUP }} | jq '.[0]["ipAddress"]' | tr -d '\"')" >> $GITHUB_ENV
81+
82+
- name: EnableAZVMSSH
83+
uses: azure/CLI@v1
84+
with:
85+
azcliversion: latest
86+
inlinescript: |
87+
az vm run-command invoke --command-id RunPowerShellScript -n winTestVM -g ${{ matrix.AZURE_RESOURCE_GROUP }} --scripts @$GITHUB_WORKSPACE/script/setup/enable_ssh_windows.ps1 --parameters 'SSHPublicKey=${{ env.SSH_PUB_KEY }}'
88+
89+
- name: TestSSHConnection
90+
run: |
91+
if ! ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "hostname";
92+
then
93+
exit 1
94+
fi
95+
96+
- name: PrepareTestingEnv
97+
run: |
98+
scp -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} $GITHUB_WORKSPACE/script/setup/prepare_env_windows.ps1 azureuser@${{ env.VM_PUB_IP }}:/prepare_env_windows.ps1
99+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "c:\\prepare_env_windows.ps1"
100+
101+
- name: MakeContainerDBins
102+
run: |
103+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "git clone http://github.com/containerd/containerd c:\\containerd "
104+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "cd c:\containerd ; make binaries"
105+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "git clone http://github.com/Microsoft/hcsshim c:\containerd\hcsshim "
106+
107+
# Get shim commit from containerd local repo
108+
SHIM_COMMIT=$(grep 'Microsoft/hcsshim' go.mod | awk '{ print $2 }');
109+
110+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "cd c:\containerd\hcsshim; git fetch --tags origin $SHIM_COMMIT ; \
111+
git checkout $SHIM_COMMIT ; go build -mod=vendor -o ${{ env.REMOTE_VM_BIN_PATH }}\containerd-shim-runhcs-v1.exe .\cmd\containerd-shim-runhcs-v1"
112+
113+
- name: RunIntegrationTests
114+
run: |
115+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "sh.exe -c 'cd /c/containerd && (make integration | tee /c/Logs/integration.log)'"
116+
ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "sh.exe -c 'cat /c/Logs/integration.log | go-junit-report.exe > /c/Logs/junit_00.xml'"
117+
118+
# CRI-integration tests for Windows PR is not merged. TO DO (adelina-t): enable these when PR #5163 merges.
119+
#
120+
# - name: PrepareRepoList
121+
# run: |
122+
# ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "sh -c 'cat > c:/repolist.yaml'" <<'EOF'
123+
# dockerLibraryRegistry: docker.io/claudiubelu
124+
# k8sCriContainerdRegistry: docker.io/claudiubelu
125+
# k8sGcrRegistry: docker.io/claudiubelu
126+
# EOF
127+
128+
# - name: RunCRIIntegrationTests
129+
# run: |
130+
# ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "sh.exe -s" <<EOF
131+
# cd c:/containerd
132+
# ./script/setup/install-cni-windows
133+
# export KUBE_TEST_REPO_LIST=c:/repolist.yaml
134+
# make cri-integration | tee c:/Logs/cri-integration.log
135+
# EOF
136+
# ssh -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }} "sh.exe -c 'cat c:\Logs\cri-integration.log | go-junit-report.exe > c:/Logs/junit_01.xml' "
137+
138+
- name: PullLogsFromWinNode
139+
run: |
140+
scp -i $HOME/.ssh/id_rsa ${{ env.SSH_OPTS }} azureuser@${{ env.VM_PUB_IP }}:c:/Logs/*.xml ${{ env.LOGS_DIR }}/artifacts/
141+
for f in $(ls ${{ env.LOGS_DIR }}/artifacts/*.xml); do
142+
xmlstarlet ed -d "/testsuites/testsuite/properties" $f > ${{ env.LOGS_DIR }}/$(basename $f)
143+
mv ${{ env.LOGS_DIR }}/$(basename $f) $f
144+
done
145+
146+
- name: FinishJob
147+
run: |
148+
jq -n --arg result SUCCESS --arg timestamp $(date +%s) '$timestamp|tonumber|{timestamp:.,$result}' > ${{ env.LOGS_DIR }}/finished.json
149+
echo "${{ env.STARTED_TIME }}" > $HOME/latest-build.txt
150+
151+
- name: SetUpCloudSDK
152+
uses: google-github-actions/setup-gcloud@master
153+
with:
154+
project_id: ${{ secrets.GCP_PROJECT_ID }}
155+
service_account_key: ${{ secrets.GCP_SA_KEY }}
156+
export_default_credentials: true
157+
158+
- name: UploadArtifacts
159+
run: |
160+
gsutil cp -r ${{ env.LOGS_DIR }} ${{ matrix.GOOGLE_BUCKET }}
161+
gsutil cp $HOME/latest-build.txt ${{ matrix.GOOGLE_BUCKET }}
162+
163+
- name: ResourceCleanup
164+
uses: azure/CLI@v1
165+
with:
166+
azcliversion: latest
167+
inlinescript: |
168+
az group delete -g ${{ matrix.AZURE_RESOURCE_GROUP }} --yes
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Param(
2+
[parameter(Mandatory=$true)]
3+
[string]$SSHPublicKey
4+
)
5+
6+
$ErrorActionPreference = "Stop"
7+
8+
9+
function Set-SSHPublicKey {
10+
if(!$SSHPublicKey) {
11+
return
12+
}
13+
$authorizedKeysFile = Join-Path $env:ProgramData "ssh\administrators_authorized_keys"
14+
Set-Content -Path $authorizedKeysFile -Value $SSHPublicKey -Encoding ascii
15+
$acl = Get-Acl $authorizedKeysFile
16+
$acl.SetAccessRuleProtection($true, $false)
17+
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators", "FullControl", "Allow")
18+
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM", "FullControl", "Allow")
19+
$acl.SetAccessRule($administratorsRule)
20+
$acl.SetAccessRule($systemRule)
21+
$acl | Set-Acl
22+
}
23+
24+
# Install OpenSSH
25+
$(
26+
27+
Get-WindowsCapability -Online -Name OpenSSH* | Add-WindowsCapability -Online
28+
Set-Service -Name sshd -StartupType Automatic
29+
Start-Service sshd
30+
31+
# Authorize SSH key
32+
Set-SSHPublicKey
33+
34+
# Set PowerShell as default shell
35+
New-ItemProperty -Force -Path "HKLM:\SOFTWARE\OpenSSH" -PropertyType String `
36+
-Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
37+
) *>$1 >> c:\output.txt

script/setup/install-cni-windows

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
set -eu -o pipefail
1818

1919
DESTDIR="${DESTDIR:-"C:\\Program Files\\containerd"}"
20-
WINCNI_BIN_DIR="${DESTDIR}/cni"
20+
WINCNI_BIN_DIR="${DESTDIR}/cni/bin"
2121
WINCNI_PKG=github.com/Microsoft/windows-container-networking
2222
WINCNI_VERSION=aa10a0b31e9f72937063436454def1760b858ee2
2323

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Prepare windows environment for building and running containerd tests
2+
3+
$PACKAGES= "mingw", "git", "golang", "make"
4+
5+
write-host "Downloading chocolatey package"
6+
curl.exe -L "https://packages.chocolatey.org/chocolatey.0.10.15.nupkg" -o 'c:\choco.zip'
7+
Expand-Archive "c:\choco.zip" -DestinationPath "c:\choco"
8+
9+
write-host "Installing choco"
10+
& "c:\choco\tools\chocolateyInstall.ps1"
11+
12+
write-host "Set choco.exe path."
13+
$env:PATH+=";C:\ProgramData\chocolatey\bin"
14+
15+
write-host "Install necessary packages"
16+
17+
foreach ($package in $PACKAGES) {
18+
choco.exe install $package --yes
19+
}
20+
21+
write-host "Set up environment."
22+
23+
$path = ";c:\Program Files\Git\bin;c:\Program Files\Go\bin;c:\Users\azureuser\go\bin;c:\containerd\bin"
24+
$env:PATH+=$path
25+
26+
write-host $env:PATH
27+
28+
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, 'User')
29+
30+
# Prepare Log dir
31+
mkdir c:\Logs
32+
33+
# Pull junit conversion tool
34+
go get -u github.com/jstemmer/go-junit-report
35+
36+
# Get critctl tool. Used for cri-integration tests
37+
$CRICTL_DOWNLOAD_URL="https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.21.0/crictl-v1.21.0-windows-amd64.tar.gz"
38+
curl.exe -L $CRICTL_DOWNLOAD_URL -o c:\crictl.tar.gz
39+
tar -xvf c:\crictl.tar.gz
40+
mv crictl.exe c:\Users\azureuser\go\bin\crictl.exe # Move crictl somewhere in path

0 commit comments

Comments
 (0)