@@ -726,9 +726,8 @@ public void EndToEnd_SingleArch_NoRid()
726
726
public void EndToEndMultiArch_LocalRegistry ( )
727
727
{
728
728
string imageName = NewImageName ( ) ;
729
- string imageTag = "1.0" ;
730
- string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
731
- string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
729
+ string tag = "1.0" ;
730
+ string image = $ "{ imageName } :{ tag } ";
732
731
733
732
// Create a new console project
734
733
DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
@@ -741,7 +740,7 @@ public void EndToEndMultiArch_LocalRegistry()
741
740
"/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
742
741
$ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
743
742
$ "/p:ContainerRepository={ imageName } ",
744
- $ "/p:ContainerImageTag={ imageTag } ",
743
+ $ "/p:ContainerImageTag={ tag } ",
745
744
"/p:EnableSdkContainerSupport=true" )
746
745
. WithWorkingDirectory ( newProjectDir . FullName )
747
746
. Execute ( ) ;
@@ -752,33 +751,53 @@ public void EndToEndMultiArch_LocalRegistry()
752
751
commandResult . Should ( ) . Pass ( )
753
752
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
754
753
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
755
- . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local registry")
756
- . And . HaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local registry")
757
- . And . NotHaveStdOutContaining ( "Pushed image index" ) ;
754
+ . And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-x64'")
755
+ . And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-arm64'")
756
+ . And . HaveStdOutContaining ( $ "Pushed image '{ image } ' to local registry") ;
757
+
758
+ //Multi-arch oci images that are loaded to docker can only be run by their image id
759
+ string imageId = GetImageId ( image ) ;
758
760
759
761
// Check that the containers can be run
760
762
CommandResult processResultX64 = ContainerCli . RunCommand (
761
763
_testOutput ,
762
764
"--rm" ,
765
+ "--platform" ,
766
+ "linux/amd64" ,
763
767
"--name" ,
764
768
$ "test-container-{ imageName } -x64",
765
- imageX64 )
769
+ imageId )
766
770
. Execute ( ) ;
767
771
processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
768
772
769
773
CommandResult processResultArm64 = ContainerCli . RunCommand (
770
774
_testOutput ,
771
775
"--rm" ,
776
+ "--platform" ,
777
+ "linux/arm64" ,
772
778
"--name" ,
773
779
$ "test-container-{ imageName } -arm64",
774
- imageArm64 )
780
+ imageId )
775
781
. Execute ( ) ;
776
782
processResultArm64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
777
783
778
784
// Cleanup
779
785
newProjectDir . Delete ( true ) ;
780
786
}
781
787
788
+ private string GetImageId ( string image )
789
+ {
790
+ CommandResult commandResult = ContainerCli . ImagesCommand ( _testOutput , "--format" , "\" {{.ID}}\" " , image )
791
+ . Execute ( ) ;
792
+ commandResult . Should ( ) . Pass ( ) ;
793
+
794
+ var output = commandResult . StdOut . Split ( "\n " ) . Select ( s => s . Trim ( '"' ) ) . ToList ( ) ;
795
+
796
+ output . Should ( ) . NotBeNullOrEmpty ( ) . And . OnlyContain ( s => s == output [ 0 ] ) ;
797
+
798
+ return output [ 0 ] ;
799
+ }
800
+
782
801
[ DockerAvailableFact ]
783
802
public void MultiArchStillAllowsSingleRID ( )
784
803
{
0 commit comments