|
14 | 14 |
|
15 | 15 | from samcli.lib.utils import osutils |
16 | 16 | from samcli.local.docker.utils import get_validated_container_client |
| 17 | +from samcli.local.docker.image_build_client import CLIBuildClient |
| 18 | +from samcli.local.docker.container_client_factory import ContainerClientFactory |
17 | 19 | from samcli.yamlhelper import yaml_parse |
18 | 20 | from tests.testing_utils import ( |
19 | 21 | IS_WINDOWS, |
@@ -1869,6 +1871,50 @@ def _verify_build_succeeds(self, build_dir): |
1869 | 1871 | self.assertIn("BuildImageFunction", build_dir_files) |
1870 | 1872 |
|
1871 | 1873 |
|
| 1874 | +@skipIf(SKIP_DOCKER_TESTS, SKIP_DOCKER_MESSAGE) |
| 1875 | +class TestBuildImageWithBuildkit(BuildIntegBase): |
| 1876 | + """Test building image functions with buildkit""" |
| 1877 | + |
| 1878 | + template = "template_image.yaml" |
| 1879 | + function_logical_id = "ImageFunction" |
| 1880 | + |
| 1881 | + def test_build_image_function_with_buildkit(self): |
| 1882 | + client = ContainerClientFactory.create_client() |
| 1883 | + is_available, error_msg = CLIBuildClient.is_available(client.get_runtime_type()) |
| 1884 | + |
| 1885 | + if not is_available: |
| 1886 | + self.skipTest(f"Buildkit not available: {error_msg}") |
| 1887 | + |
| 1888 | + tag = uuid4().hex |
| 1889 | + overrides = { |
| 1890 | + "Runtime": "3.12", |
| 1891 | + "Handler": "main.handler", |
| 1892 | + "DockerFile": "Dockerfile", |
| 1893 | + "Tag": tag, |
| 1894 | + } |
| 1895 | + cmdlist = self.get_command_list(parameter_overrides=overrides, use_buildkit=True) |
| 1896 | + |
| 1897 | + command_result = run_command(cmdlist, cwd=self.working_dir) |
| 1898 | + self.assertEqual(command_result.process.returncode, 0) |
| 1899 | + |
| 1900 | + # Verify image was built |
| 1901 | + self._verify_image_build_artifact( |
| 1902 | + self.built_template, |
| 1903 | + self.function_logical_id, |
| 1904 | + "ImageUri", |
| 1905 | + f"{self.function_logical_id.lower()}:{tag}", |
| 1906 | + ) |
| 1907 | + |
| 1908 | + # Verify image works |
| 1909 | + expected = {"pi": "3.14"} |
| 1910 | + self._verify_invoke_built_function( |
| 1911 | + self.built_template, |
| 1912 | + self.function_logical_id, |
| 1913 | + self._make_parameter_override_arg(overrides), |
| 1914 | + expected, |
| 1915 | + ) |
| 1916 | + |
| 1917 | + |
1872 | 1918 | @parameterized_class( |
1873 | 1919 | ("template", "stack_paths", "layer_full_path", "function_full_paths", "invoke_error_message"), |
1874 | 1920 | [ |
|
0 commit comments