Skip to content

Commit

Permalink
test: GHA to Execute Test without Docker Running (aws#5290)
Browse files Browse the repository at this point in the history
* test: Test without Docker running

* Add build test

* Run install

* Remove success condition

* Add continue on error

* Add continue on error

* Separate tests

* Fix test name

* Require new test

* Address comments

* Attempt to parameterize for windows

* Attempt to parameterize for windows

* Attempt to parameterize for windows

* Set samdev in environment

* Move skip to top of test class
  • Loading branch information
mildaniel authored and Leonardo Gama committed Jun 22, 2023
1 parent c9818f3 commit 56dac6b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 16 deletions.
44 changes: 43 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ jobs:
- make-pr
- integration-tests
- smoke-and-functional-tests
- docker-disabled
steps:
- name: report-failure
if : |
needs.make-pr.result != 'success' ||
needs.integration-tests.result != 'success' ||
needs.smoke-and-functional-tests.result != 'success'
needs.smoke-and-functional-tests.result != 'success' ||
needs.docker-disabled.result != 'success'
run: exit 1
- name: report-success
run: exit 0
Expand Down Expand Up @@ -187,3 +189,43 @@ jobs:
run: make init
- name: Run functional & smoke tests
run: pytest -vv -n 4 tests/functional tests/smoke

docker-disabled:
name: Docker-disabled Tests / ${{ matrix.os }}
if: github.repository_owner == 'aws'
runs-on: ${{ matrix.os }}
env:
SAM_CLI_DEV: "1"
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# These are the versions of Python that correspond to the supported Lambda runtimes
python-version: |
3.10
3.9
3.8
3.7
- name: Init samdev
run: make init
- name: Stop Docker Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo systemctl stop docker
- name: Stop Docker Windows
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: stop-service docker
- name: Check Docker not Running
run: docker info
id: run-docker-info
continue-on-error: true
- name: Report failure
if: steps.run-docker-info.outcome == 'success'
run: exit 1
- name: Run tests without Docker
run: pytest -vv tests/integration/buildcmd/test_build_cmd.py -k TestBuildCommand_PythonFunctions_WithoutDocker
62 changes: 47 additions & 15 deletions tests/integration/buildcmd/test_build_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,34 +398,64 @@ def _validate_skipped_built_function(
"overrides",
"runtime",
"codeuri",
"use_container",
"check_function_only",
"prop",
),
[
("template.yaml", "Function", True, "python3.7", "Python", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "Python", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.7", "PythonPEP600", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "PythonPEP600", False, False, "CodeUri"),
("template.yaml", "Function", True, "python3.7", "Python", "use_container", False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "Python", "use_container", False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", "use_container", False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", "use_container", False, "CodeUri"),
("template.yaml", "Function", True, "python3.7", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.7", "PythonPEP600", False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "PythonPEP600", False, "CodeUri"),
],
)
class TestBuildCommand_PythonFunctions(BuildIntegPythonBase):
class TestBuildCommand_PythonFunctions_WithoutDocker(BuildIntegPythonBase):
overrides = True
runtime = "python3.9"
codeuri = "Python"
check_function_only = False
use_container = False

@pytest.mark.flaky(reruns=3)
def test_with_default_requirements(self):
self._test_with_default_requirements(
self.runtime,
self.codeuri,
self.use_container,
self.test_data_path,
do_override=self.overrides,
check_function_only=self.check_function_only,
)


@skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE)
@parameterized_class(
(
"template",
"FUNCTION_LOGICAL_ID",
"overrides",
"runtime",
"codeuri",
"check_function_only",
"prop",
),
[
("template.yaml", "Function", True, "python3.7", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"),
],
)
class TestBuildCommand_PythonFunctions_WithDocker(BuildIntegPythonBase):
overrides = True
runtime = "python3.9"
codeuri = "Python"
use_container = "use_container"
check_function_only = False

@pytest.mark.flaky(reruns=3)
def test_with_default_requirements(self):
if self.use_container and (SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD):
self.skipTest(SKIP_DOCKER_MESSAGE)
self._test_with_default_requirements(
self.runtime,
self.codeuri,
Expand Down Expand Up @@ -465,7 +495,9 @@ def test_with_default_requirements(self):
),
],
)
class TestBuildCommand_PythonFunctions_CDK(TestBuildCommand_PythonFunctions):
class TestBuildCommand_PythonFunctions_CDK(TestBuildCommand_PythonFunctions_WithoutDocker):
use_container = False

@pytest.mark.flaky(reruns=3)
def test_cdk_app_with_default_requirements(self):
self._test_with_default_requirements(
Expand Down

0 comments on commit 56dac6b

Please sign in to comment.