Skip to content

Commit 3ce2cb3

Browse files
committed
test: add basic integration test
1 parent dff542b commit 3ce2cb3

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

tests/integration/buildcmd/build_integ_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def get_command_list(
114114
config_file=None,
115115
save_params=False,
116116
project_root_dir=None,
117+
use_buildkit=False,
117118
):
118119
command_list = [self.cmd, "build"]
119120

@@ -140,6 +141,9 @@ def get_command_list(
140141
if debug:
141142
command_list += ["--debug"]
142143

144+
if use_buildkit:
145+
command_list += ["--use-buildkit"]
146+
143147
if cached:
144148
command_list += ["--cached"]
145149

tests/integration/buildcmd/test_build_cmd.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
from samcli.lib.utils import osutils
1616
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
1719
from samcli.yamlhelper import yaml_parse
1820
from tests.testing_utils import (
1921
IS_WINDOWS,
@@ -1869,6 +1871,50 @@ def _verify_build_succeeds(self, build_dir):
18691871
self.assertIn("BuildImageFunction", build_dir_files)
18701872

18711873

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+
18721918
@parameterized_class(
18731919
("template", "stack_paths", "layer_full_path", "function_full_paths", "invoke_error_message"),
18741920
[

0 commit comments

Comments
 (0)