Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add runtime markers to base classes in build tests #6044

Merged
merged 11 commits into from
Oct 10, 2023
22 changes: 17 additions & 5 deletions appveyor-linux-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ image:

configuration:
- BuildIntegTesting
- BuildIntegTestingJavaPythonProvided
- BuildIntegTestingArm64
- BuildIntegTestingArm64Java
- AllTerraformBuildTesting
- DeployIntegTesting
- PackageIntegTesting
Expand Down Expand Up @@ -170,19 +172,29 @@ for:
- configuration: BuildIntegTesting

test_script:
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'not java and not python and not provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

# Set JAVA_HOME to java11
- sh: "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
- sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java11.json"
- matrix:
only:
- configuration: BuildIntegTestingJavaPythonProvided

test_script:
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'java or python or provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java-python-provided.json"

# Integ testing build arm64 functions
- matrix:
only:
- configuration: BuildIntegTestingArm64

test_script:
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64.json"
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py -m 'not java' --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64.json"

- matrix:
only:
- configuration: BuildIntegTestingArm64Java

test_script:
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py -m 'java' --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64-java.json"

# Integ testing Terraform build
-
Expand Down
42 changes: 22 additions & 20 deletions appveyor-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ image:

configuration:
- BuildIntegTesting
- BuildIntegTestingJavaPythonProvided
- BuildIntegTestingArm64
- BuildIntegTestingArm64Java
- AllTerraformBuildTesting
- DeployIntegTesting
- PackageIntegTesting
- DeleteIntegTesting
- PackageAndDeleteIntegTesting
- SyncIntegTesting
- LocalIntegTesting
- EndToEndTesting
Expand Down Expand Up @@ -158,20 +159,30 @@ for:
- configuration: BuildIntegTesting

test_script:
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'not java and not python and not provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

- matrix:
only:
- configuration: BuildIntegTestingJavaPythonProvided

test_script:
- sh: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'java or python or provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java-python-provided.json"

# Set JAVA_HOME to java11
- sh: "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
- sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java11.json"

# Integ testing build arm64 functions
-
matrix:
only:
- configuration: BuildIntegTestingArm64

test_script:
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64.json"
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py -m 'not java' --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64.json"

- matrix:
only:
- configuration: BuildIntegTestingArm64Java

test_script:
- sh: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py -m 'java' --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64-java.json"

# Integ testing Terraform build
-
Expand Down Expand Up @@ -200,23 +211,14 @@ for:
test_script:
- sh: "pytest -vv tests/integration/deploy -n 4 --reruns 4 --dist=loadgroup --json-report --json-report-file=TEST_REPORT-integration-deploy.json"

# Integ testing package
-
matrix:
only:
- configuration: PackageIntegTesting

test_script:
- sh: "pytest -vv tests/integration/package -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package.json"

# Integ testing delete
# Integ testing package & delete
-
matrix:
only:
- configuration: DeleteIntegTesting
- configuration: PackageAndDeleteIntegTesting

test_script:
- sh: "pytest -vv tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-delete.json"
- sh: "pytest -vv tests/integration/package tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package-delete.json"

# Integ testing sync
-
Expand Down
12 changes: 10 additions & 2 deletions appveyor-windows-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ clone_folder: C:\source

configuration:
- BuildIntegTesting
- BuildIntegTestingJavaPythonProvided
- BuildIntegTestingArm64
- AllTerraformBuildTesting
- DeployIntegTesting
Expand Down Expand Up @@ -175,11 +176,18 @@ on_finish:


for:
#Integ testing build, regression
#Integ testing build
- matrix:
only:
- configuration: BuildIntegTesting

test_script:
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'not java and not python and not provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

- matrix:
only:
- configuration: BuildIntegTestingJavaPythonProvided

build_script:
# install Rust in build_script to not override the default "install" actions
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
Expand All @@ -198,7 +206,7 @@ for:
- cargo lambda -V

test_script:
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'java or python or provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

#Integ testing build arm64
- matrix:
Expand Down
47 changes: 31 additions & 16 deletions appveyor-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ clone_folder: C:\source

configuration:
- BuildIntegTesting
- BuildIntegTestingJavaPythonProvided
- BuildIntegTestingArm64
- AllTerraformBuildTesting
- DeployIntegTesting
- PackageIntegTesting
- DeleteIntegTesting
- PackageAndDeleteIntegTesting
- SyncIntegTesting
- LocalIntegTesting
- EndToEndTesting
Expand Down Expand Up @@ -171,6 +171,13 @@ for:
only:
- configuration: BuildIntegTesting

test_script:
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'not java and not python and not provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

- matrix:
only:
- configuration: BuildIntegTestingJavaPythonProvided

build_script:
# install Rust in build_script to not override the default "install" actions
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
Expand All @@ -189,17 +196,33 @@ for:
- cargo lambda -V

test_script:
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"
- ps: "pytest -vv -n 2 --reruns 3 tests/integration/buildcmd -m 'java or python or provided' --ignore=tests/integration/buildcmd/test_build_cmd_arm64.py --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java-python-provided.json"

#Integ testing build arm64
- matrix:
only:
- configuration: BuildIntegTestingArm64

build_script:
# install Rust in build_script to not override the default "install" actions
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain stable
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- set RUST_BACKTRACE=1
- rustup toolchain install stable --profile minimal --no-self-update
- rustup default stable
- rustup target add x86_64-unknown-linux-gnu --toolchain stable
- rustup target add aarch64-unknown-linux-gnu --toolchain stable
- ps: "choco install zig"
- ps: Invoke-WebRequest -Uri https://github.com/cargo-lambda/cargo-lambda/releases/download/$env:CARGO_LAMBDA_VERSION/cargo-lambda-$env:CARGO_LAMBDA_VERSION.windows-x64.zip -OutFile C:\Users\appveyor\cargo-lambda.zip
- ps: Expand-Archive -DestinationPath C:\Users\appveyor\.cargo\bin C:\Users\appveyor\cargo-lambda.zip
- rustc -V
- cargo -V
- cargo lambda -V

test_script:
- ps: "pytest -vv --reruns 3 tests/integration/buildcmd/test_build_cmd_arm64.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd-arm64.json"


#Integ testing Terraform build
- matrix:
only:
Expand All @@ -213,21 +236,13 @@ for:
- ps: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"
- ps: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json"

# Integ testing package
- matrix:
only:
- configuration: PackageIntegTesting

test_script:
- ps: "pytest -vv tests/integration/package -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package.json"

# Integ testing delete
# Integ testing package & delete
- matrix:
only:
- configuration: DeleteIntegTesting
- configuration: PackageAndDeleteIntegTesting

test_script:
- ps: "pytest -vv tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-delete.json"
- ps: "pytest -vv tests/integration/package tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package-delete.json"

# Integ testing sync
- matrix:
Expand Down
10 changes: 9 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ filterwarnings =
ignore::DeprecationWarning:samcli.lib.samlib.wrapper
ignore::DeprecationWarning:samtranslator.validator.validator
ignore::DeprecationWarning:docker
ignore::DeprecationWarning:urllib3.poolmanager
default::ResourceWarning
; The following deprecation warnings are treated as failures unless we explicitly tell pytest not to
; Remove once we no longer support python3.7
ignore::boto3.exceptions.PythonDeprecationWarning

markers =
ruby
nodejs
golang
java
python
provided
dotnet
9 changes: 9 additions & 0 deletions tests/integration/buildcmd/build_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import jmespath
from pathlib import Path

import pytest
from parameterized import parameterized_class

from samcli.commands.build.utils import MountMode
Expand Down Expand Up @@ -253,6 +254,7 @@ def get_override(self, runtime, code_uri, architecture, handler):
return overrides


@pytest.mark.ruby
class BuildIntegRubyBase(BuildIntegBase):
EXPECTED_FILES_PROJECT_MANIFEST = {"app.rb"}
EXPECTED_RUBY_GEM = "aws-eventstream"
Expand Down Expand Up @@ -334,6 +336,7 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files,
self.assertTrue(any([True if self.EXPECTED_RUBY_GEM in gem else False for gem in os.listdir(str(gem_path))]))


@pytest.mark.nodejs
class BuildIntegEsbuildBase(BuildIntegBase):
FUNCTION_LOGICAL_ID = "Function"
# Everything should be minifed to one line and a second line for the sourcemap mapping
Expand Down Expand Up @@ -427,6 +430,7 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files)
self.assertEqual(actual_files, expected_files)


@pytest.mark.nodejs
class BuildIntegNodeBase(BuildIntegBase):
EXPECTED_FILES_PROJECT_MANIFEST = {"node_modules", "main.js"}
EXPECTED_NODE_MODULES = {"minimal-request-promise"}
Expand Down Expand Up @@ -505,6 +509,7 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files,
self.assertEqual(actual_files, expected_modules)


@pytest.mark.golang
class BuildIntegGoBase(BuildIntegBase):
FUNCTION_LOGICAL_ID = "Function"
EXPECTED_FILES_PROJECT_MANIFEST = {"hello-world"}
Expand Down Expand Up @@ -568,6 +573,7 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files)
self.assertEqual(actual_files, expected_files)


@pytest.mark.java
class BuildIntegJavaBase(BuildIntegBase):
FUNCTION_LOGICAL_ID = "Function"

Expand Down Expand Up @@ -650,6 +656,7 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files,
self.assertEqual(lib_dir_contents, expected_modules)


@pytest.mark.python
class BuildIntegPythonBase(BuildIntegBase):
EXPECTED_FILES_PROJECT_MANIFEST = {
"__init__.py",
Expand Down Expand Up @@ -747,6 +754,7 @@ def _get_python_version(self):
return "python3.10"


@pytest.mark.provided
class BuildIntegProvidedBase(BuildIntegBase):
EXPECTED_FILES_PROJECT_MANIFEST = {"__init__.py", "main.py", "requests", "requirements.txt"}

Expand Down Expand Up @@ -1021,6 +1029,7 @@ def rust_parameterized_class(cls):
return cls


@pytest.mark.provided
class BuildIntegRustBase(BuildIntegBase):
FUNCTION_LOGICAL_ID = "Function"
EXPECTED_FILES_PROJECT_MANIFEST = {"bootstrap"}
Expand Down
Loading
Loading