Skip to content

Commit

Permalink
Updating tests to use new est\internal package
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
  • Loading branch information
helsaawy committed May 5, 2022
1 parent e34a177 commit f621e11
Show file tree
Hide file tree
Showing 55 changed files with 7,951 additions and 491 deletions.
16 changes: 8 additions & 8 deletions test/cri-containerd/clone_test.go
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)

Expand Down Expand Up @@ -240,7 +240,7 @@ func cleanupContainer(t *testing.T, client runtime.RuntimeServiceClient, ctx con
// cloned container from that template.
func Test_CloneContainer_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -265,7 +265,7 @@ func Test_CloneContainer_WCOW(t *testing.T) {
// A test for creating multiple clones(3 clones) from one template container.
func Test_MultiplClonedContainers_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -302,7 +302,7 @@ func Test_MultiplClonedContainers_WCOW(t *testing.T) {
// container.
func Test_NormalContainerInClonedPod_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -342,7 +342,7 @@ func Test_NormalContainerInClonedPod_WCOW(t *testing.T) {
// of those pods.
func Test_CloneContainersWithClonedPodPool_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -390,7 +390,7 @@ func Test_CloneContainersWithClonedPodPool_WCOW(t *testing.T) {

func Test_ClonedContainerRunningAfterDeletingTemplate(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -424,7 +424,7 @@ func Test_ClonedContainerRunningAfterDeletingTemplate(t *testing.T) {
// can be made from each of them simultaneously.
func Test_MultipleTemplateAndClones_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -467,7 +467,7 @@ func Test_MultipleTemplateAndClones_WCOW(t *testing.T) {
// and verifies that the request correctly fails with an error.
func Test_VerifyCloneAndTemplateConfig(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
4 changes: 2 additions & 2 deletions test/cri-containerd/container_downlevel_test.go
Expand Up @@ -7,13 +7,13 @@ import (
"testing"

"github.com/Microsoft/hcsshim/osversion"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)

func Test_CreateContainer_DownLevel_WCOW_Hypervisor(t *testing.T) {
requireFeatures(t, featureWCOWHypervisor)
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

pullRequiredImages(t, []string{imageWindowsNanoserver17763})

Expand Down
8 changes: 4 additions & 4 deletions test/cri-containerd/container_layers_packing_test.go
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
)

const (
Expand All @@ -38,7 +38,7 @@ func validateTargets(ctx context.Context, t *testing.T, deviceNumber int, podID
}

func Test_Container_Layer_Packing_On_VPMem(t *testing.T) {
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

client := newTestRuntimeClient(t)
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -93,7 +93,7 @@ func Test_Container_Layer_Packing_On_VPMem(t *testing.T) {
}

func Test_Many_Container_Layers_Supported_On_VPMem(t *testing.T) {
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

client := newTestRuntimeClient(t)
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -124,7 +124,7 @@ func Test_Many_Container_Layers_Supported_On_VPMem(t *testing.T) {
}

func Test_Annotation_Disable_Multi_Mapping(t *testing.T) {
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

client := newTestRuntimeClient(t)
ctx, cancel := context.WithCancel(context.Background())
Expand Down
4 changes: 2 additions & 2 deletions test/cri-containerd/container_update_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)

Expand All @@ -33,7 +33,7 @@ func calculateJobCPURate(hostProcs uint32, processorCount uint32) uint32 {
}

func Test_Container_UpdateResources_CPUShare(t *testing.T) {
testutilities.RequiresBuild(t, osversion.V20H2)
require.Build(t, osversion.V20H2)
type config struct {
name string
requiredFeatures []string
Expand Down
6 changes: 3 additions & 3 deletions test/cri-containerd/createcontainer_test.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/Microsoft/hcsshim/internal/memory"
"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)

Expand Down Expand Up @@ -845,7 +845,7 @@ func Test_CreateContainer_CPUShares_LCOW(t *testing.T) {

func Test_CreateContainer_Mount_File_LCOW(t *testing.T) {
requireFeatures(t, featureLCOW)
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

pullRequiredLCOWImages(t, []string{imageLcowK8sPause, imageLcowAlpine})

Expand Down Expand Up @@ -890,7 +890,7 @@ func Test_CreateContainer_Mount_File_LCOW(t *testing.T) {

func Test_CreateContainer_Mount_ReadOnlyFile_LCOW(t *testing.T) {
requireFeatures(t, featureLCOW)
testutilities.RequiresBuild(t, osversion.V19H1)
require.Build(t, osversion.V19H1)

pullRequiredLCOWImages(t, []string{imageLcowK8sPause, imageLcowAlpine})

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions test/cri-containerd/main_test.go
Expand Up @@ -14,8 +14,7 @@ import (
"time"

"github.com/Microsoft/hcsshim/osversion"
_ "github.com/Microsoft/hcsshim/test/functional/manifest"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
testutilities "github.com/Microsoft/hcsshim/test/internal"
"github.com/containerd/containerd"
eventtypes "github.com/containerd/containerd/api/events"
eventsapi "github.com/containerd/containerd/api/services/events/v1"
Expand All @@ -25,6 +24,8 @@ import (
"github.com/gogo/protobuf/types"
"google.golang.org/grpc"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

_ "github.com/Microsoft/hcsshim/test/internal/manifest"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions test/cri-containerd/runpodsandbox_test.go
Expand Up @@ -22,7 +22,8 @@ import (
"github.com/Microsoft/hcsshim/internal/shimdiag"
"github.com/Microsoft/hcsshim/osversion"
"github.com/Microsoft/hcsshim/pkg/annotations"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/require"
testuvm "github.com/Microsoft/hcsshim/test/internal/uvm"
"github.com/containerd/containerd/log"
"golang.org/x/sys/windows"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
Expand Down Expand Up @@ -982,7 +983,7 @@ func Test_RunPodSandbox_Mount_SandboxDir_NoShare_WCOW(t *testing.T) {
}

func Test_RunPodSandbox_CPUGroup(t *testing.T) {
testutilities.RequiresBuild(t, osversion.V21H1)
require.Build(t, osversion.V21H1)
ctx := context.Background()
presentID := "FA22A12C-36B3-486D-A3E9-BC526C2B450B"

Expand Down Expand Up @@ -1062,7 +1063,7 @@ func createExt4VHD(ctx context.Context, t *testing.T, path string) {
log.L.Logger.SetOutput(io.Discard)
defer log.L.Logger.SetOutput(origLogOut)
}
uvm := testutilities.CreateLCOWUVM(ctx, t, t.Name()+"-createExt4VHD")
uvm := testuvm.CreateAndStartLCOW(ctx, t, t.Name()+"-createExt4VHD")
defer uvm.Close()

if err := lcow.CreateScratch(ctx, uvm, path, 2, ""); err != nil {
Expand Down
33 changes: 17 additions & 16 deletions test/runhcs/e2e_matrix_test.go
Expand Up @@ -19,7 +19,8 @@ import (
"github.com/Microsoft/go-winio/vhd"
"github.com/Microsoft/hcsshim/osversion"
runhcs "github.com/Microsoft/hcsshim/pkg/go-runhcs"
testutilities "github.com/Microsoft/hcsshim/test/functional/utilities"
"github.com/Microsoft/hcsshim/test/internal/layers"
"github.com/Microsoft/hcsshim/test/internal/require"
runc "github.com/containerd/go-runc"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
Expand Down Expand Up @@ -167,15 +168,15 @@ func testWindows(t *testing.T, version int, isolated bool) {
var err error

// Make the bundle
bundle := testutilities.CreateTempDir(t)
bundle := t.TempDir()
defer func() {
if err == nil {
os.RemoveAll(bundle)
} else {
t.Errorf("additional logs at bundle path: %v", bundle)
}
}()
scratch := testutilities.CreateTempDir(t)
scratch := t.TempDir()
defer func() {
vhd.DetachVhd(filepath.Join(scratch, "sandbox.vhdx"))
os.RemoveAll(scratch)
Expand All @@ -195,7 +196,7 @@ func testWindows(t *testing.T, version int, isolated bool) {

// Get the LayerFolders
imageName := getWindowsImageNameByVersion(t, version)
layers := testutilities.LayerFolders(t, imageName)
layers := layers.LayerFolders(t, imageName)
for _, layer := range layers {
g.AddWindowsLayerFolders(layer)
}
Expand Down Expand Up @@ -311,25 +312,25 @@ func testLCOWPod(t *testing.T) {
}

func Test_RS1_Argon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS1)
require.ExactBuild(t, osversion.RS1)

testWindows(t, osversion.RS1, false)
}

func Test_RS1_Xenon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS1)
require.ExactBuild(t, osversion.RS1)

testWindows(t, osversion.RS1, true)
}

func Test_RS3_Argon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS3)
require.ExactBuild(t, osversion.RS3)

testWindows(t, osversion.RS3, false)
}

func Test_RS3_Xenon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS3)
require.ExactBuild(t, osversion.RS3)

guests := []int{osversion.RS1, osversion.RS3}
for _, g := range guests {
Expand All @@ -338,13 +339,13 @@ func Test_RS3_Xenon(t *testing.T) {
}

func Test_RS4_Argon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS4)
require.ExactBuild(t, osversion.RS4)

testWindows(t, osversion.RS4, false)
}

func Test_RS4_Xenon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS4)
require.ExactBuild(t, osversion.RS4)

guests := []int{osversion.RS1, osversion.RS3, osversion.RS4}
for _, g := range guests {
Expand All @@ -353,19 +354,19 @@ func Test_RS4_Xenon(t *testing.T) {
}

func Test_RS5_Argon(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

testWindows(t, osversion.RS5, false)
}

func Test_RS5_ArgonPods(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

testWindowsPod(t, osversion.RS5, false)
}

func Test_RS5_UVMAndContainer(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

guests := []int{osversion.RS1, osversion.RS3, osversion.RS4, osversion.RS5}
for _, g := range guests {
Expand All @@ -374,19 +375,19 @@ func Test_RS5_UVMAndContainer(t *testing.T) {
}

func Test_RS5_UVMPods(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

testWindowsPod(t, osversion.RS5, true)
}

func Test_RS5_LCOW(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

testLCOW(t)
}

func Test_RS5_LCOW_UVMPods(t *testing.T) {
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

testLCOWPod(t)
}
2 changes: 1 addition & 1 deletion test/runhcs/runhcs_test.go
Expand Up @@ -4,5 +4,5 @@
package runhcs

import (
_ "github.com/Microsoft/hcsshim/test/functional/manifest"
_ "github.com/Microsoft/hcsshim/test/internal/manifest"
)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f621e11

Please sign in to comment.