44package functional
55
66import (
7+ "path/filepath"
78 "testing"
89
910 ctrdoci "github.com/containerd/containerd/oci"
1011 cri_util "github.com/containerd/containerd/pkg/cri/util"
1112
1213 "github.com/Microsoft/hcsshim/internal/hcsoci"
14+ "github.com/Microsoft/hcsshim/internal/layers"
1315 "github.com/Microsoft/hcsshim/internal/resources"
1416 "github.com/Microsoft/hcsshim/osversion"
1517
1618 "github.com/Microsoft/hcsshim/test/internal/cmd"
1719 "github.com/Microsoft/hcsshim/test/internal/container"
18- "github.com/Microsoft/hcsshim/test/internal/layers"
20+ testlayers "github.com/Microsoft/hcsshim/test/internal/layers"
1921 "github.com/Microsoft/hcsshim/test/internal/oci"
2022 "github.com/Microsoft/hcsshim/test/pkg/require"
2123 "github.com/Microsoft/hcsshim/test/pkg/uvm"
@@ -32,13 +34,13 @@ func BenchmarkLCOW_Container(b *testing.B) {
3234
3335 b .Run ("Create" , func (b * testing.B ) {
3436 vm := uvm .CreateAndStartLCOWFromOpts (ctx , b , defaultLCOWOptions (b ))
35- cache := layers .CacheFile (ctx , b , "" )
37+ cache := testlayers .CacheFile (ctx , b , "" )
3638
3739 b .StopTimer ()
3840 b .ResetTimer ()
3941 for i := 0 ; i < b .N ; i ++ {
4042 id := cri_util .GenerateID ()
41- scratch , _ := layers .ScratchSpace (ctx , b , vm , "" , "" , cache )
43+ scratch , _ := testlayers .ScratchSpace (ctx , b , vm , "" , "" , cache )
4244 spec := oci .CreateLinuxSpec (ctx , b , id ,
4345 oci .DefaultLinuxSpecOpts (id ,
4446 ctrdoci .WithProcessArgs ("/bin/sh" , "-c" , "true" ),
@@ -53,6 +55,15 @@ func BenchmarkLCOW_Container(b *testing.B) {
5355 NetworkNamespace : "" ,
5456 }
5557
58+ co .LCOWLayers = & layers.LCOWLayers {
59+ Layers : make ([]* layers.LCOWLayer , 0 , len (ls )),
60+ ScratchVHDPath : filepath .Join (scratch , "sandbox.vhdx" ),
61+ }
62+
63+ for _ , p := range ls {
64+ co .LCOWLayers .Layers = append (co .LCOWLayers .Layers , & layers.LCOWLayer {VHDPath : filepath .Join (p , "layer.vhd" )})
65+ }
66+
5667 b .StartTimer ()
5768 c , r , err := hcsoci .CreateContainer (ctx , co )
5869 if err != nil {
@@ -79,13 +90,13 @@ func BenchmarkLCOW_Container(b *testing.B) {
7990
8091 b .Run ("Start" , func (b * testing.B ) {
8192 vm := uvm .CreateAndStartLCOWFromOpts (ctx , b , defaultLCOWOptions (b ))
82- cache := layers .CacheFile (ctx , b , "" )
93+ cache := testlayers .CacheFile (ctx , b , "" )
8394
8495 b .StopTimer ()
8596 b .ResetTimer ()
8697 for i := 0 ; i < b .N ; i ++ {
8798 id := cri_util .GenerateID ()
88- scratch , _ := layers .ScratchSpace (ctx , b , vm , "" , "" , cache )
99+ scratch , _ := testlayers .ScratchSpace (ctx , b , vm , "" , "" , cache )
89100 spec := oci .CreateLinuxSpec (ctx , b , id ,
90101 oci .DefaultLinuxSpecOpts (id ,
91102 ctrdoci .WithProcessArgs ("/bin/sh" , "-c" , "true" ),
@@ -111,13 +122,13 @@ func BenchmarkLCOW_Container(b *testing.B) {
111122
112123 b .Run ("InitExec" , func (b * testing.B ) {
113124 vm := uvm .CreateAndStartLCOWFromOpts (ctx , b , defaultLCOWOptions (b ))
114- cache := layers .CacheFile (ctx , b , "" )
125+ cache := testlayers .CacheFile (ctx , b , "" )
115126
116127 b .StopTimer ()
117128 b .ResetTimer ()
118129 for i := 0 ; i < b .N ; i ++ {
119130 id := cri_util .GenerateID ()
120- scratch , _ := layers .ScratchSpace (ctx , b , vm , "" , "" , cache )
131+ scratch , _ := testlayers .ScratchSpace (ctx , b , vm , "" , "" , cache )
121132 spec := oci .CreateLinuxSpec (ctx , b , id ,
122133 oci .DefaultLinuxSpecOpts (id ,
123134 ctrdoci .WithProcessArgs ("/bin/sh" , "-c" , oci .TailNullArgs ),
@@ -144,13 +155,13 @@ func BenchmarkLCOW_Container(b *testing.B) {
144155
145156 b .Run ("InitExecKill" , func (b * testing.B ) {
146157 vm := uvm .CreateAndStartLCOWFromOpts (ctx , b , defaultLCOWOptions (b ))
147- cache := layers .CacheFile (ctx , b , "" )
158+ cache := testlayers .CacheFile (ctx , b , "" )
148159
149160 b .StopTimer ()
150161 b .ResetTimer ()
151162 for i := 0 ; i < b .N ; i ++ {
152163 id := cri_util .GenerateID ()
153- scratch , _ := layers .ScratchSpace (ctx , b , vm , "" , "" , cache )
164+ scratch , _ := testlayers .ScratchSpace (ctx , b , vm , "" , "" , cache )
154165 spec := oci .CreateLinuxSpec (ctx , b , id ,
155166 oci .DefaultLinuxSpecOpts (id ,
156167 ctrdoci .WithProcessArgs ("/bin/sh" , "-c" , oci .TailNullArgs ),
@@ -172,13 +183,13 @@ func BenchmarkLCOW_Container(b *testing.B) {
172183
173184 b .Run ("ContainerKill" , func (b * testing.B ) {
174185 vm := uvm .CreateAndStartLCOWFromOpts (ctx , b , defaultLCOWOptions (b ))
175- cache := layers .CacheFile (ctx , b , "" )
186+ cache := testlayers .CacheFile (ctx , b , "" )
176187
177188 b .StopTimer ()
178189 b .ResetTimer ()
179190 for i := 0 ; i < b .N ; i ++ {
180191 id := cri_util .GenerateID ()
181- scratch , _ := layers .ScratchSpace (ctx , b , vm , "" , "" , cache )
192+ scratch , _ := testlayers .ScratchSpace (ctx , b , vm , "" , "" , cache )
182193 spec := oci .CreateLinuxSpec (ctx , b , id ,
183194 oci .DefaultLinuxSpecOpts (id ,
184195 ctrdoci .WithProcessArgs ("/bin/sh" , "-c" , "true" ),
0 commit comments