@@ -30,6 +30,7 @@ load("//contrib:test.bzl", "container_test")
3030load (":apple.bzl" , "create_banana_directory" )
3131load (":empty_layers.bzl" , "empty_layers" )
3232load (":pull_info_validation_test.bzl" , "pull_info_validation_test" )
33+ load (":transitions.bzl" , "templated_file" , "transition_test" )
3334
3435package (default_visibility = ["//visibility:public" ])
3536
@@ -999,3 +1000,80 @@ container_bundle(
9991000 "localhost:5000/image4:latest" : "//testdata:with_double_label" ,
10001001 },
10011002)
1003+
1004+ genrule (
1005+ name = "got_os" ,
1006+ outs = ["got_os.txt" ],
1007+ cmd = select ({
1008+ "@platforms//os:windows" : "echo windows > \" $@\" " ,
1009+ "@platforms//os:linux" : "echo linux > \" $@\" " ,
1010+ "@platforms//os:macos" : "echo macos > \" $@\" " ,
1011+ }),
1012+ )
1013+
1014+ genrule (
1015+ name = "got_arch" ,
1016+ outs = ["got_arch.txt" ],
1017+ cmd = select ({
1018+ "@platforms//cpu:arm64" : "echo arm64 > \" $@\" " ,
1019+ "@platforms//cpu:aarch64" : "echo arm64 > \" $@\" " ,
1020+ "@platforms//cpu:x86_64" : "echo x86_64 > \" $@\" " ,
1021+ "@platforms//cpu:arm" : "echo arm > \" $@\" " ,
1022+ }),
1023+ )
1024+
1025+ container_image (
1026+ name = "transitioned_image" ,
1027+ architecture = "arm64" ,
1028+ files = [
1029+ ":got_arch" ,
1030+ ":got_os" ,
1031+ ],
1032+ operating_system = "windows" ,
1033+ )
1034+
1035+ templated_file (
1036+ name = "transitions_off" ,
1037+ out = "transitions_off.yaml" ,
1038+ substitutions =
1039+ select ({
1040+ "@platforms//os:linux" : ["%WANT_OS%=linux" ],
1041+ "@platforms//os:macos" : ["%WANT_OS%=macos" ],
1042+ }) + select ({
1043+ "@platforms//cpu:arm64" : ["%WANT_ARCH%=arm64" ],
1044+ "@platforms//cpu:aarch64" : ["%WANT_ARCH%=arm64" ],
1045+ "@platforms//cpu:x86_64" : ["%WANT_ARCH%=x86_64" ],
1046+ }),
1047+ template = "//tests/container/configs:transitions_off.yaml.tpl" ,
1048+ )
1049+
1050+ container_test (
1051+ name = "_transitions_on_test_base" ,
1052+ configs = ["//tests/container/configs:transitions_on.yaml" ],
1053+ driver = "tar" ,
1054+ image = ":transitioned_image" ,
1055+ # marked manual, because it will only pass if transitions are enabled
1056+ # enabled or disabled
1057+ tags = ["manual" ],
1058+ )
1059+
1060+ transition_test (
1061+ name = "transitions_on_test" ,
1062+ actual = ":_transitions_on_test_base" ,
1063+ transitions_enabled = True ,
1064+ )
1065+
1066+ container_test (
1067+ name = "_transitions_off_test_base" ,
1068+ configs = ["transitions_off" ],
1069+ driver = "tar" ,
1070+ image = ":transitioned_image" ,
1071+ # marked manual, because it will only pass if transitions are disabled
1072+ tags = ["manual" ],
1073+ )
1074+
1075+ transition_test (
1076+ name = "transitions_off_test" ,
1077+ actual = ":_transitions_off_test_base" ,
1078+ transitions_enabled = False ,
1079+ )
0 commit comments