@@ -562,10 +562,9 @@ func startAndWaitTask(ctx context.Context, t *testing.T, c containerd.Container)
562
562
return stdout .String ()
563
563
}
564
564
565
- func TestCreateContainerWithSameName_Isolated (t * testing.T ) {
566
- internal .RequiresIsolation (t )
567
-
565
+ func testCreateContainerWithSameName (t * testing.T , opts ... oci.SpecOpts ) {
568
566
ctx := namespaces .WithNamespace (context .Background (), "default" )
567
+ withNewSpec := containerd .WithNewSpec (append ([]oci.SpecOpts {oci .WithProcessArgs ("echo" , "hello" )}, opts ... )... )
569
568
570
569
client , err := containerd .New (containerdSockPath , containerd .WithDefaultRuntime (firecrackerRuntime ))
571
570
require .NoError (t , err , "unable to create client to containerd service at %s, is containerd running?" , containerdSockPath )
@@ -583,7 +582,7 @@ func TestCreateContainerWithSameName_Isolated(t *testing.T) {
583
582
containerName ,
584
583
containerd .WithSnapshotter (naiveSnapshotterName ),
585
584
containerd .WithNewSnapshot (snapshotName , image ),
586
- containerd . WithNewSpec ( oci . WithProcessArgs ( "echo" , "hello" )) ,
585
+ withNewSpec ,
587
586
)
588
587
require .NoError (t , err , "failed to create container %s" , containerName )
589
588
require .Equal (t , "hello\n " , startAndWaitTask (ctx , t , c1 ))
@@ -600,7 +599,7 @@ func TestCreateContainerWithSameName_Isolated(t *testing.T) {
600
599
containerName ,
601
600
containerd .WithSnapshotter (naiveSnapshotterName ),
602
601
containerd .WithNewSnapshot (snapshotName , image ),
603
- containerd . WithNewSpec ( oci . WithProcessArgs ( "echo" , "hello" )) ,
602
+ withNewSpec ,
604
603
)
605
604
require .NoError (t , err , "failed to create container %s" , containerName )
606
605
require .Equal (t , "hello\n " , startAndWaitTask (ctx , t , c2 ))
@@ -611,3 +610,10 @@ func TestCreateContainerWithSameName_Isolated(t *testing.T) {
611
610
_ , err = os .Stat (containerPath )
612
611
require .True (t , os .IsNotExist (err ))
613
612
}
613
+
614
+ func TestCreateContainerWithSameName_Isolated (t * testing.T ) {
615
+ internal .RequiresIsolation (t )
616
+
617
+ testCreateContainerWithSameName (t )
618
+ testCreateContainerWithSameName (t , firecrackeroci .WithVMID ("reuse-same-vm" ))
619
+ }
0 commit comments