Skip to content

Commit

Permalink
Updating tests to use new test\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 Jul 21, 2022
1 parent 55b3fad commit 8aae1ff
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 56 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
13 changes: 7 additions & 6 deletions test/cri-containerd/jobcontainer_test.go
Expand Up @@ -16,12 +16,13 @@ import (
"time"

"github.com/Microsoft/go-winio/vhd"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

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

func getJobContainerPodRequestWCOW(t *testing.T) *runtime.RunPodSandboxRequest {
Expand Down Expand Up @@ -418,7 +419,7 @@ func Test_RunContainer_HostVolumes_JobContainer_WCOW(t *testing.T) {

func Test_RunContainer_JobContainer_VolumeMount(t *testing.T) {
client := newTestRuntimeClient(t)
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

dir := t.TempDir()

Expand Down Expand Up @@ -601,7 +602,7 @@ func Test_RunContainer_JobContainer_Environment(t *testing.T) {

func Test_RunContainer_WorkingDirectory_JobContainer_WCOW(t *testing.T) {
client := newTestRuntimeClient(t)
testutilities.RequiresExactBuild(t, osversion.RS5)
require.ExactBuild(t, osversion.RS5)

type config struct {
name string
Expand Down Expand Up @@ -737,7 +738,7 @@ func Test_DoubleQuoting_JobContainer_WCOW(t *testing.T) {
// Test that mounts show up at the expected destination if the host supports file binding.
func Test_BindSupport_JobContainer_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWProcess, featureHostProcess)
testutilities.RequiresBuild(t, osversion.V20H1)
require.Build(t, osversion.V20H1)

pullRequiredImages(t, []string{imageWindowsNanoserver})
client := newTestRuntimeClient(t)
Expand Down Expand Up @@ -793,7 +794,7 @@ func Test_BindSupport_JobContainer_WCOW(t *testing.T) {
// Test that mounts are unique per container even if the same container path is used.
func Test_BindSupport_MultipleContainers_JobContainer_WCOW(t *testing.T) {
requireFeatures(t, featureWCOWProcess, featureHostProcess)
testutilities.RequiresBuild(t, osversion.V20H1)
require.Build(t, osversion.V20H1)

pullRequiredImages(t, []string{imageWindowsNanoserver})
client := newTestRuntimeClient(t)
Expand Down
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
2 changes: 0 additions & 2 deletions test/go.mod
Expand Up @@ -24,7 +24,6 @@ require (
)

require (
github.com/akavel/rsrc v0.10.2 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
Expand All @@ -44,7 +43,6 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
Expand Down
7 changes: 0 additions & 7 deletions test/go.sum
Expand Up @@ -54,8 +54,6 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -385,8 +383,6 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8=
github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -714,8 +710,6 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw=
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
Expand Down Expand Up @@ -811,7 +805,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
Expand Down

0 comments on commit 8aae1ff

Please sign in to comment.