@@ -746,16 +746,15 @@ public void EndToEndMultiArch_LocalRegistry()
746
746
. Execute ( ) ;
747
747
748
748
// Check that the app was published for each RID,
749
- // images were created locally for each RID
750
- // and image index was NOT created
749
+ // one image was created locally
751
750
commandResult . Should ( ) . Pass ( )
752
751
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
753
752
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
754
753
. And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-x64'")
755
754
. And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-arm64'")
756
755
. And . HaveStdOutContaining ( $ "Pushed image '{ image } ' to local registry") ;
757
756
758
- //Multi-arch oci images that are loaded to docker can only be run by their image id
757
+ //Multi-arch oci tarballs that are loaded to docker can only be run by their image id
759
758
string imageId = GetImageId ( image ) ;
760
759
761
760
// Check that the containers can be run
@@ -927,12 +926,10 @@ private string GetPublishArtifactsPath(string projectDir, string rid, string con
927
926
public void EndToEndMultiArch_ArchivePublishing ( )
928
927
{
929
928
string imageName = NewImageName ( ) ;
930
- string imageTag = "1.0" ;
931
- string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
932
- string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
929
+ string tag = "1.0" ;
930
+ string image = $ "{ imageName } :{ tag } ";
933
931
string archiveOutput = Path . Combine ( TestSettings . TestArtifactsDirectory , "tarballs-output" ) ;
934
- string imageX64Tarball = Path . Combine ( archiveOutput , $ "{ imageName } -linux-x64.tar.gz") ;
935
- string imageArm64Tarball = Path . Combine ( archiveOutput , $ "{ imageName } -linux-arm64.tar.gz") ;
932
+ string imageTarball = Path . Combine ( archiveOutput , $ "{ imageName } .tar.gz") ;
936
933
937
934
// Create a new console project
938
935
DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
@@ -946,49 +943,51 @@ public void EndToEndMultiArch_ArchivePublishing()
946
943
$ "/p:ContainerArchiveOutputPath={ archiveOutput } ",
947
944
$ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
948
945
$ "/p:ContainerRepository={ imageName } ",
949
- $ "/p:ContainerImageTag={ imageTag } ",
946
+ $ "/p:ContainerImageTag={ tag } ",
950
947
"/p:EnableSdkContainerSupport=true" )
951
948
. WithWorkingDirectory ( newProjectDir . FullName )
952
949
. Execute ( ) ;
953
950
954
951
// Check that the app was published for each RID,
955
- // images were created locally for each RID
956
- // and image index was NOT created
952
+ // one image was created in local archive
957
953
commandResult . Should ( ) . Pass ( )
958
954
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
959
955
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
960
- . And . HaveStdOutContaining ( $ "Pushed image '{ imageX64 } ' to local archive at ' { imageX64Tarball } '")
961
- . And . HaveStdOutContaining ( $ "Pushed image '{ imageArm64 } ' to local archive at ' { imageArm64Tarball } '")
962
- . And . NotHaveStdOutContaining ( "Pushed image index " ) ;
956
+ . And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-x64 '")
957
+ . And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-arm64 '")
958
+ . And . HaveStdOutContaining ( $ "Pushed image ' { image } ' to local archive at ' { imageTarball } ' ") ;
963
959
964
960
// Check that tarballs were created
965
- File . Exists ( imageX64Tarball ) . Should ( ) . BeTrue ( ) ;
966
- File . Exists ( imageArm64Tarball ) . Should ( ) . BeTrue ( ) ;
961
+ File . Exists ( imageTarball ) . Should ( ) . BeTrue ( ) ;
967
962
968
- // Load the images from the tarballs
969
- ContainerCli . LoadCommand ( _testOutput , "--input" , imageX64Tarball )
970
- . Execute ( )
971
- . Should ( ) . Pass ( ) ;
972
- ContainerCli . LoadCommand ( _testOutput , "--input" , imageArm64Tarball )
963
+ // Load the multi-arch image from the tarball
964
+ ContainerCli . LoadCommand ( _testOutput , "--input" , imageTarball )
973
965
. Execute ( )
974
966
. Should ( ) . Pass ( ) ;
975
967
968
+ //Multi-arch oci tarballs that are loaded to docker can only be run by their image id
969
+ string imageId = GetImageId ( image ) ;
970
+
976
971
// Check that the containers can be run
977
972
CommandResult processResultX64 = ContainerCli . RunCommand (
978
973
_testOutput ,
979
974
"--rm" ,
975
+ "--platform" ,
976
+ "linux/amd64" ,
980
977
"--name" ,
981
978
$ "test-container-{ imageName } -x64",
982
- imageX64 )
979
+ imageId )
983
980
. Execute ( ) ;
984
981
processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
985
982
986
983
CommandResult processResultArm64 = ContainerCli . RunCommand (
987
984
_testOutput ,
988
985
"--rm" ,
986
+ "--platform" ,
987
+ "linux/arm64" ,
989
988
"--name" ,
990
989
$ "test-container-{ imageName } -arm64",
991
- imageArm64 )
990
+ imageId )
992
991
. Execute ( ) ;
993
992
processResultArm64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "Hello, World!" ) ;
994
993
@@ -1118,8 +1117,8 @@ public void EndToEndMultiArch_ContainerRuntimeIdentifiersOverridesRuntimeIdentif
1118
1117
commandResult . Should ( ) . Pass ( )
1119
1118
. And . NotHaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-x64" ) )
1120
1119
. And . HaveStdOutContaining ( GetPublishArtifactsPath ( newProjectDir . FullName , "linux-arm64" ) )
1121
- . And . NotHaveStdOutContaining ( $ "Pushed image '{ imageName } : { imageTag } -linux-x64' to local registry ")
1122
- . And . HaveStdOutContaining ( $ "Pushed image '{ imageName } : { imageTag } -linux-arm64' to local registry ") ;
1120
+ . And . NotHaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-x64' ")
1121
+ . And . HaveStdOutContaining ( $ "Building image '{ imageName } ' for runtime identifier 'linux-arm64' ") ;
1123
1122
1124
1123
// Cleanup
1125
1124
newProjectDir . Delete ( true ) ;
@@ -1129,9 +1128,8 @@ public void EndToEndMultiArch_ContainerRuntimeIdentifiersOverridesRuntimeIdentif
1129
1128
public void EndToEndMultiArch_EnvVariables ( )
1130
1129
{
1131
1130
string imageName = NewImageName ( ) ;
1132
- string imageTag = "1.0" ;
1133
- string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
1134
- string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
1131
+ string tag = "1.0" ;
1132
+ string image = $ "{ imageName } :{ tag } ";
1135
1133
1136
1134
// Create new console app, set ContainerEnvironmentVariables, and set to output env variable
1137
1135
DirectoryInfo newProjectDir = CreateNewProject ( "console" ) ;
@@ -1160,31 +1158,37 @@ public void EndToEndMultiArch_EnvVariables()
1160
1158
"/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
1161
1159
$ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
1162
1160
$ "/p:ContainerRepository={ imageName } ",
1163
- $ "/p:ContainerImageTag={ imageTag } ",
1161
+ $ "/p:ContainerImageTag={ tag } ",
1164
1162
"/p:EnableSdkContainerSupport=true" )
1165
1163
. WithWorkingDirectory ( newProjectDir . FullName )
1166
1164
. Execute ( )
1167
1165
. Should ( ) . Pass ( ) ;
1168
1166
1169
- // Check that the env var is printed
1167
+ string imageId = GetImageId ( image ) ;
1168
+
1169
+ // Check that the env var is printed for linux/amd64 platform
1170
1170
string containerNameX64 = $ "test-container-{ imageName } -x64";
1171
1171
CommandResult processResultX64 = ContainerCli . RunCommand (
1172
1172
_testOutput ,
1173
1173
"--rm" ,
1174
+ "--platform" ,
1175
+ "linux/amd64" ,
1174
1176
"--name" ,
1175
1177
containerNameX64 ,
1176
- imageX64 )
1178
+ imageId )
1177
1179
. Execute ( ) ;
1178
1180
processResultX64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "FooBar" ) ;
1179
1181
1180
- // Check that the env var is printed
1182
+ // Check that the env var is printed for linux/arm64 platform
1181
1183
string containerNameArm64 = $ "test-container-{ imageName } -arm64";
1182
1184
CommandResult processResultArm64 = ContainerCli . RunCommand (
1183
1185
_testOutput ,
1184
1186
"--rm" ,
1187
+ "--platform" ,
1188
+ "linux/arm64" ,
1185
1189
"--name" ,
1186
1190
containerNameArm64 ,
1187
- imageArm64 )
1191
+ imageId )
1188
1192
. Execute ( ) ;
1189
1193
processResultArm64 . Should ( ) . Pass ( ) . And . HaveStdOut ( "FooBar" ) ;
1190
1194
@@ -1196,9 +1200,8 @@ public void EndToEndMultiArch_EnvVariables()
1196
1200
public void EndToEndMultiArch_Ports ( )
1197
1201
{
1198
1202
string imageName = NewImageName ( ) ;
1199
- string imageTag = "1.0" ;
1200
- string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64";
1201
- string imageArm64 = $ "{ imageName } :{ imageTag } -linux-arm64";
1203
+ string tag = "1.0" ;
1204
+ string image = $ "{ imageName } :{ tag } ";
1202
1205
1203
1206
// Create new web app, set ContainerPort
1204
1207
DirectoryInfo newProjectDir = CreateNewProject ( "webapp" ) ;
@@ -1222,38 +1225,44 @@ public void EndToEndMultiArch_Ports()
1222
1225
"/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
1223
1226
$ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
1224
1227
$ "/p:ContainerRepository={ imageName } ",
1225
- $ "/p:ContainerImageTag={ imageTag } ",
1228
+ $ "/p:ContainerImageTag={ tag } ",
1226
1229
"/p:EnableSdkContainerSupport=true" )
1227
1230
. WithWorkingDirectory ( newProjectDir . FullName )
1228
1231
. Execute ( )
1229
1232
. Should ( ) . Pass ( ) ;
1230
1233
1231
- // Check that the ports are correct
1234
+ string imageId = GetImageId ( image ) ;
1235
+
1236
+ // Check that the ports are correct for linux/amd64 platform
1232
1237
var containerNameX64 = $ "test-container-{ imageName } -x64";
1233
1238
CommandResult processResultX64 = ContainerCli . RunCommand (
1234
1239
_testOutput ,
1235
1240
"--rm" ,
1241
+ "--platform" ,
1242
+ "linux/amd64" ,
1236
1243
"--name" ,
1237
1244
containerNameX64 ,
1238
1245
"-P" ,
1239
1246
"--detach" ,
1240
- imageX64 )
1247
+ imageId )
1241
1248
. Execute ( ) ;
1242
1249
processResultX64 . Should ( ) . Pass ( ) ;
1243
1250
1244
1251
// 8080 is the default port
1245
1252
CheckPorts ( containerNameX64 , [ 8080 , 8082 , 8083 ] , [ 8081 ] ) ;
1246
1253
1247
- // Check that the ports are correct
1254
+ // Check that the ports are correct for linux/arm64 platform
1248
1255
var containerNameArm64 = $ "test-container-{ imageName } -arm64";
1249
1256
CommandResult processResultArm64 = ContainerCli . RunCommand (
1250
1257
_testOutput ,
1251
1258
"--rm" ,
1259
+ "--platform" ,
1260
+ "linux/arm64" ,
1252
1261
"--name" ,
1253
1262
containerNameArm64 ,
1254
1263
"-P" ,
1255
1264
"--detach" ,
1256
- imageArm64 )
1265
+ imageId )
1257
1266
. Execute ( ) ;
1258
1267
processResultArm64 . Should ( ) . Pass ( ) ;
1259
1268
@@ -1291,8 +1300,8 @@ private void CheckPorts(string containerName, int[] correctPorts, int[] incorrec
1291
1300
public void EndToEndMultiArch_Labels ( )
1292
1301
{
1293
1302
string imageName = NewImageName ( ) ;
1294
- string imageTag = "1.0" ;
1295
- string imageX64 = $ "{ imageName } :{ imageTag } -linux-x64 ";
1303
+ string tag = "1.0" ;
1304
+ string image = $ "{ imageName } :{ tag } ";
1296
1305
1297
1306
// Create new console app
1298
1307
DirectoryInfo newProjectDir = CreateNewProject ( "webapp" ) ;
@@ -1305,17 +1314,19 @@ public void EndToEndMultiArch_Labels()
1305
1314
"/p:RuntimeIdentifiers=\" linux-x64;linux-arm64\" " ,
1306
1315
$ "/p:ContainerBaseImage={ DockerRegistryManager . FullyQualifiedBaseImageAspNet } ",
1307
1316
$ "/p:ContainerRepository={ imageName } ",
1308
- $ "/p:ContainerImageTag={ imageTag } ",
1317
+ $ "/p:ContainerImageTag={ tag } ",
1309
1318
"/p:EnableSdkContainerSupport=true" )
1310
1319
. WithWorkingDirectory ( newProjectDir . FullName )
1311
1320
. Execute ( )
1312
1321
. Should ( ) . Pass ( ) ;
1313
1322
1323
+ string imageId = GetImageId ( image ) ;
1324
+
1314
1325
// Check that labels are set
1315
1326
CommandResult inspectResult = ContainerCli . InspectCommand (
1316
1327
_testOutput ,
1317
1328
"--format={{json .Config.Labels}}" ,
1318
- imageX64 )
1329
+ imageId )
1319
1330
. Execute ( ) ;
1320
1331
inspectResult . Should ( ) . Pass ( ) ;
1321
1332
var labels = JsonSerializer . Deserialize < Dictionary < string , string > > ( inspectResult . StdOut ) ;
0 commit comments