Enable integration tests against sandboxed CRI

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2022-07-13 12:02:06 -07:00
parent cf5df7e4ac
commit b8e93774c1
2 changed files with 20 additions and 1 deletions

View File

@ -252,6 +252,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows-2019, windows-2022] os: [windows-2019, windows-2022]
enable_cri_sandboxes: [ "", "sandboxed"]
defaults: defaults:
run: run:
@ -335,6 +336,7 @@ jobs:
- name: Integration 1 - name: Integration 1
env: env:
CGO_ENABLED: 1 CGO_ENABLED: 1
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-serial-junit.xml GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-serial-junit.xml
run: mingw32-make.exe integration run: mingw32-make.exe integration
@ -344,17 +346,20 @@ jobs:
TESTFLAGS_PARALLEL: 1 TESTFLAGS_PARALLEL: 1
EXTRA_TESTFLAGS: "-short" EXTRA_TESTFLAGS: "-short"
CGO_ENABLED: 1 CGO_ENABLED: 1
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-parallel-junit.xml GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-parallel-junit.xml
run: mingw32-make.exe integration run: mingw32-make.exe integration
- name: CRI Integration Test - name: CRI Integration Test
env: env:
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
TEST_IMAGE_LIST: ${{github.workspace}}/repolist.toml TEST_IMAGE_LIST: ${{github.workspace}}/repolist.toml
run: | run: |
make cri-integration make cri-integration
- name: cri-tools critest - name: cri-tools critest
env: env:
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
CRI_TEST_IMAGES: ${{github.workspace}}/cri-test-images.yaml CRI_TEST_IMAGES: ${{github.workspace}}/cri-test-images.yaml
shell: powershell shell: powershell
run: | run: |
@ -368,6 +373,7 @@ jobs:
$skip = "-ginkgo.skip=runtime should support exec with tty=true and stdin=true" $skip = "-ginkgo.skip=runtime should support exec with tty=true and stdin=true"
} }
critest.exe --runtime-endpoint=npipe://.//pipe//containerd-containerd --test-images-file='${{env.CRI_TEST_IMAGES}}' --report-dir='${{github.workspace}}/critestreport' $skip critest.exe --runtime-endpoint=npipe://.//pipe//containerd-containerd --test-images-file='${{env.CRI_TEST_IMAGES}}' --report-dir='${{github.workspace}}/critestreport' $skip
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
if: always() if: always()
with: with:
@ -386,6 +392,7 @@ jobs:
matrix: matrix:
runtime: [io.containerd.runtime.v1.linux, io.containerd.runc.v1, io.containerd.runc.v2] runtime: [io.containerd.runtime.v1.linux, io.containerd.runc.v1, io.containerd.runc.v2]
runc: [runc, crun] runc: [runc, crun]
enable_cri_sandboxes: [ "", "sandboxed"]
exclude: exclude:
- runtime: io.containerd.runc.v1 - runtime: io.containerd.runc.v1
runc: crun runc: crun
@ -439,6 +446,7 @@ jobs:
GOPROXY: direct GOPROXY: direct
TEST_RUNTIME: ${{ matrix.runtime }} TEST_RUNTIME: ${{ matrix.runtime }}
RUNC_FLAVOR: ${{ matrix.runc }} RUNC_FLAVOR: ${{ matrix.runc }}
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-serial-junit.xml GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-serial-junit.xml
run: | run: |
extraflags="" extraflags=""
@ -453,6 +461,7 @@ jobs:
GOPROXY: direct GOPROXY: direct
TEST_RUNTIME: ${{ matrix.runtime }} TEST_RUNTIME: ${{ matrix.runtime }}
RUNC_FLAVOR: ${{ matrix.runc }} RUNC_FLAVOR: ${{ matrix.runc }}
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-parallel-junit.xml GOTESTSUM_JUNITFILE: ${{github.workspace}}/test-integration-parallel-junit.xml
run: | run: |
extraflags="" extraflags=""
@ -464,12 +473,14 @@ jobs:
- name: CRI Integration Test - name: CRI Integration Test
env: env:
TEST_RUNTIME: ${{ matrix.runtime }} TEST_RUNTIME: ${{ matrix.runtime }}
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
run: | run: |
CONTAINERD_RUNTIME=$TEST_RUNTIME make cri-integration CONTAINERD_RUNTIME=$TEST_RUNTIME make cri-integration
- name: cri-tools critest - name: cri-tools critest
env: env:
TEST_RUNTIME: ${{ matrix.runtime }} TEST_RUNTIME: ${{ matrix.runtime }}
ENABLE_CRI_SANDBOXES: ${{ matrix.enable_cri_sandboxes }}
run: | run: |
BDIR="$(mktemp -d -p $PWD)" BDIR="$(mktemp -d -p $PWD)"
mkdir -p ${BDIR}/{root,state} mkdir -p ${BDIR}/{root,state}

View File

@ -19,6 +19,7 @@ package cri
import ( import (
"flag" "flag"
"fmt" "fmt"
"os"
"path/filepath" "path/filepath"
"github.com/containerd/containerd" "github.com/containerd/containerd"
@ -31,6 +32,7 @@ import (
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
"github.com/containerd/containerd/leases" "github.com/containerd/containerd/leases"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/pkg/cri/sbserver"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services" "github.com/containerd/containerd/services"
@ -97,7 +99,13 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) {
return nil, fmt.Errorf("failed to create containerd client: %w", err) return nil, fmt.Errorf("failed to create containerd client: %w", err)
} }
s, err := server.NewCRIService(c, client) var s server.CRIService
if os.Getenv("ENABLE_CRI_SANDBOXES") != "" {
log.G(ctx).Warn("using experimental CRI Sandbox server")
s, err = sbserver.NewCRIService(c, client)
} else {
s, err = server.NewCRIService(c, client)
}
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create CRI service: %w", err) return nil, fmt.Errorf("failed to create CRI service: %w", err)
} }