@@ -562,9 +562,27 @@ func startAndWaitTask(ctx context.Context, t *testing.T, c containerd.Container)
562
562
return stdout .String ()
563
563
}
564
564
565
- func testCreateContainerWithSameName (t * testing.T , opts ... oci. SpecOpts ) {
565
+ func testCreateContainerWithSameName (t * testing.T , vmID string ) {
566
566
ctx := namespaces .WithNamespace (context .Background (), "default" )
567
- withNewSpec := containerd .WithNewSpec (append ([]oci.SpecOpts {oci .WithProcessArgs ("echo" , "hello" )}, opts ... )... )
567
+
568
+ pluginClient , err := ttrpcutil .NewClient (containerdSockPath + ".ttrpc" )
569
+ require .NoError (t , err , "failed to create ttrpc client" )
570
+
571
+ // Explicitly specify Container Count = 2
572
+ // TODO: shouldn't it work without specifying the count?
573
+ fcClient := fccontrol .NewFirecrackerClient (pluginClient .Client ())
574
+ _ , err = fcClient .CreateVM (ctx , & proto.CreateVMRequest {
575
+ VMID : vmID ,
576
+ RootDrive : & proto.FirecrackerDrive {
577
+ PathOnHost : defaultRootfsPath ,
578
+ IsReadOnly : true ,
579
+ IsRootDevice : true ,
580
+ },
581
+ ContainerCount : 2 ,
582
+ })
583
+ require .NoError (t , err )
584
+
585
+ withNewSpec := containerd .WithNewSpec (oci .WithProcessArgs ("echo" , "hello" ), firecrackeroci .WithVMID (vmID ))
568
586
569
587
client , err := containerd .New (containerdSockPath , containerd .WithDefaultRuntime (firecrackerRuntime ))
570
588
require .NoError (t , err , "unable to create client to containerd service at %s, is containerd running?" , containerdSockPath )
@@ -614,6 +632,8 @@ func testCreateContainerWithSameName(t *testing.T, opts ...oci.SpecOpts) {
614
632
func TestCreateContainerWithSameName_Isolated (t * testing.T ) {
615
633
internal .RequiresIsolation (t )
616
634
617
- testCreateContainerWithSameName (t )
618
- testCreateContainerWithSameName (t , firecrackeroci .WithVMID ("reuse-same-vm" ))
635
+ testCreateContainerWithSameName (t , "" )
636
+
637
+ vmID := fmt .Sprintf ("same-vm-%d" , time .Now ().UnixNano ())
638
+ testCreateContainerWithSameName (t , vmID )
619
639
}
0 commit comments