Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
22e20db
fix flaky warm containers testing
moelasmar Jan 5, 2022
32d3a5f
use py3.7 instead of 3.8, as it is not available in testing windows host
moelasmar Jan 5, 2022
93f55e5
selectors are not working in windows
moelasmar Jan 5, 2022
1244fa6
ruby 2.5 is not supported, use 2.7 instead
moelasmar Jan 5, 2022
faa6123
fix the logic to wait till apis are running in windows
moelasmar Jan 5, 2022
ffba9b7
add auto generated S3 Prefix
moelasmar Jan 5, 2022
41fa022
fix ruby version
moelasmar Jan 5, 2022
a056e52
move s3 prefix creation to Setup method
moelasmar Jan 5, 2022
a338eb1
fix the sync integration testing
moelasmar Jan 5, 2022
c6b482f
Merge branch 'develop' into develop-fix-canaries
moelasmar Jan 6, 2022
c2d9567
remove appveyor sync
moelasmar Jan 6, 2022
8991df8
Merge branch 'develop' into develop-fix-canaries
mndeveci Jan 6, 2022
4ceb42b
Merge remote-tracking branch 'moelasamar-sam-cli-public/develop-fix-c…
moelasmar Jan 6, 2022
66c50af
Add TypeScript CDK V1 && V2
moelasmar Jan 19, 2022
a22ff03
Add appveyor yaml file
moelasmar Jan 19, 2022
6f790e2
Merge remote-tracking branch 'aws-sam-cli-public/develop' into develo…
moelasmar Jan 19, 2022
cf94c3d
fix appveyor yaml file
moelasmar Jan 19, 2022
d31b3b3
fix appveyor yaml file
moelasmar Jan 19, 2022
4bf9806
fix appveyor template
moelasmar Jan 19, 2022
c7a2f98
fix appveyor template - update nodejs version
moelasmar Jan 19, 2022
638e79c
fix appveyor template - install latest nodejs version
moelasmar Jan 19, 2022
378bf5b
add sudo
moelasmar Jan 19, 2022
351a5d6
testing
moelasmar Jan 19, 2022
add13bd
testing - add sudo
moelasmar Jan 19, 2022
d7774a0
testing - add sudo2
moelasmar Jan 19, 2022
47715db
testing - add sudo3
moelasmar Jan 19, 2022
ef8eeff
testing - add sudo4
moelasmar Jan 19, 2022
69b27f4
testing - add sudo5
moelasmar Jan 19, 2022
7691437
add some print out
moelasmar Jan 19, 2022
90ba68b
add some logs for investigation
moelasmar Jan 19, 2022
4d2ff46
remove bundled java test cases, and use bundled python instead
moelasmar Jan 20, 2022
be91783
add CDK python examples
moelasmar Jan 20, 2022
773ebdf
remove shared layers
moelasmar Jan 20, 2022
cc4d999
update python cdk.json files
moelasmar Jan 20, 2022
7958736
debugging
moelasmar Jan 20, 2022
c77abf2
revert debugging
moelasmar Jan 20, 2022
52bc04c
revert wrong committed changes
moelasmar Jan 20, 2022
0e48bd7
Merge branch 'develop' into sam-cdk-integration-testing
moelasmar Jan 20, 2022
25a3861
remove py2.7 installation.
moelasmar Jan 20, 2022
a5987e7
Add Java CDK application
moelasmar Jan 20, 2022
9751d71
install maven
moelasmar Jan 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions appveyor-iac-integration-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
version: 1.0.{build}
image:
- Ubuntu

environment:
AWS_DEFAULT_REGION: us-east-1
SAM_CLI_DEV: 1

matrix:

- PYTHON_VERSION: '3.6'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_37_PIP: 1
INSTALL_PY_38_PIP: 1
INSTALL_PY_39_PIP: 1
APPVEYOR_CONSOLE_DISABLE_PTY: true

- PYTHON_VERSION: '3.7'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1
INSTALL_PY_38_PIP: 1
INSTALL_PY_39_PIP: 1
APPVEYOR_CONSOLE_DISABLE_PTY: true

- PYTHON_VERSION: '3.8'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1
INSTALL_PY_37_PIP: 1
INSTALL_PY_39_PIP: 1
APPVEYOR_CONSOLE_DISABLE_PTY: true

- PYTHON_VERSION: '3.9'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1
INSTALL_PY_37_PIP: 1
INSTALL_PY_38_PIP: 1
APPVEYOR_CONSOLE_DISABLE_PTY: true

install:
# apt repo for python3.9 installation
- sh: "sudo add-apt-repository ppa:deadsnakes/ppa"
# AppVeyor's apt-get cache might be outdated, and the package could potentially be 404.
- sh: "sudo apt-get update"

- sh: "gvm use go1.15"
- sh: "echo $PATH"
- sh: "ls /usr/"
- sh: "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64"
- sh: "PATH=$JAVA_HOME/bin:$PATH"
- sh: "source ${HOME}/venv${PYTHON_VERSION}/bin/activate"
- sh: "rvm use 2.7.2"
- sh: "docker --version"
# install nodejs
- sh: "nvm install --lts=Fermium"
- sh: "node --version"
- sh: "npx --version"

# Install AWS CLI
- sh: "virtualenv aws_cli"
- sh: "./aws_cli/bin/python -m pip install awscli"
- sh: "PATH=$(echo $PWD'/aws_cli/bin'):$PATH"

# Install latest maven
- sh: "sudo apt update"
- sh: "sudo apt install maven"
- sh: "mvn --version"

- sh: "sudo apt-get -y install python3.6"
- sh: "sudo apt-get -y install python3.7"
- sh: "sudo apt-get -y install python3.8"
- sh: "sudo apt-get -y install python3.9"

- sh: "which python3.8"
- sh: "which python3.7"
- sh: "which python3.6"
- sh: "which python3.9"

- sh: "PATH=$PATH:/usr/bin/python3.9:/usr/bin/python3.8:/usr/bin/python3.7"
- sh: "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py"

- sh: "sudo apt-get -y install python3-distutils"
- sh: "sudo apt-get -y install python3.9-distutils"
- ps: "If ($env:INSTALL_PY_39_PIP) {python3.9 get-pip.py --user}"
- ps: "If ($env:INSTALL_PY_38_PIP) {python3.8 get-pip.py --user}"
- ps: "If ($env:INSTALL_PY_37_PIP) {python3.7 get-pip.py --user}"
- ps: "If ($env:INSTALL_PY_36_PIP) {python3.6 get-pip.py --user}"

# required for RIE with arm64 in linux
- sh: "docker run --rm --privileged multiarch/qemu-user-static --reset -p yes"

# update ca-certificates which causes failures with newest golang library
- sh: "sudo apt-get install --reinstall ca-certificates"

build_script:
- "python -c \"import sys; print(sys.executable)\""

test_script:
# Pre-dev Tests
- "pip install -e \".[pre-dev]\""

# Runs only in Linux, logging Public ECR when running canary and cred is available
- sh: "
if [[ -n $BY_CANARY ]];
then echo Logging in Public ECR; aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws;
fi"

- "pip install -e \".[dev]\""
- sh: "pytest -vv tests/iac_integration"
Empty file.
Empty file.
124 changes: 124 additions & 0 deletions tests/iac_integration/cdk/test_sam_cdk_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from unittest import TestCase
from subprocess import Popen, PIPE
import os
import random
from pathlib import Path
import threading

import pytest
import requests
from parameterized import parameterized_class, parameterized

from tests.testing_utils import run_command


@parameterized_class(
("cdk_project_path", "cdk_version", "cdk_stack_template"),
[
("/testdata/cdk_v1/typescript", "1.x", "TestStack.template.json"),
("/testdata/cdk_v2/typescript", "2.x", "TestStack.template.json"),
("/testdata/cdk_v1/python", "1.x", "TestStack.template.json"),
("/testdata/cdk_v2/python", "2.x", "TestStack.template.json"),
("/testdata/cdk_v1/java", "1.x", "TestStack.template.json"),
("/testdata/cdk_v2/java", "2.x", "TestStack.template.json"),
],
)
class TestSamCdkIntegration(TestCase):
integration_dir = str(Path(__file__).resolve().parents[0])
cdk_project_path = ""
cdk_version = ""
cdk_stack_template = ""

@classmethod
def setUpClass(cls):
cls.cdk_project = cls.integration_dir + cls.cdk_project_path
cls.api_port = str(TestSamCdkIntegration.random_port())
cls.build_cdk_project()
cls.build()

cls.api_thread = threading.Thread(target=cls.start_api())
cls.api_thread.setDaemon(True)
cls.api_thread.start()
cls.url = "http://127.0.0.1:{}".format(cls.api_port)

@classmethod
def build_cdk_project(cls):
command_list = ["npx", f"aws-cdk@{cls.cdk_version}", "synth", "--no-staging"]
working_dir = cls.cdk_project
result = run_command(command_list, cwd=working_dir)
if result.process.returncode != 0:
raise Exception("cdk synth command failed")

@classmethod
def build(cls):
command = "sam"
if os.getenv("SAM_CLI_DEV"):
command = "samdev"
command_list = [command, "build", "-t", cls.cdk_stack_template]
working_dir = cls.cdk_project + "/cdk.out"
result = run_command(command_list, cwd=working_dir)
if result.process.returncode != 0:
raise Exception("sam build command failed")

@classmethod
def start_api(cls):
command = "sam"
if os.getenv("SAM_CLI_DEV"):
command = "samdev"

command_list = [command, "local", "start-api", "-p", cls.api_port]

working_dir = cls.cdk_project + "/cdk.out"
cls.start_api_process = Popen(command_list, cwd=working_dir, stderr=PIPE)

while True:
line = cls.start_api_process.stderr.readline()
if "(Press CTRL+C to quit)" in str(line):
break

cls.stop_api_reading_thread = False

def read_sub_process_stderr():
while not cls.stop_api_reading_thread:
cls.start_api_process.stderr.readline()

cls.api_read_threading = threading.Thread(target=read_sub_process_stderr)
cls.api_read_threading.start()

@classmethod
def tearDownClass(cls):
# After all the tests run, we need to kill the start_lambda process.
cls.start_api_process.kill()
cls.stop_api_reading_thread = True

@staticmethod
def random_port():
return random.randint(30000, 40000)

@parameterized.expand(
[
("/httpapis/nestedPythonFunction", "Hello World from Nested Python Function Construct 7"),
("/restapis/spec/pythonFunction", "Hello World from python function construct 7"),
("/restapis/normal/pythonFunction", "Hello World from python function construct 7"),
("/restapis/normal/functionPythonRuntime", "Hello World from function construct with python runtime 7"),
("/restapis/normal/preBuiltFunctionPythonRuntime", "Hello World from python pre built function 7"),
(
"/restapis/normal/bundledFunctionPythonRuntime",
"Hello World from bundled function construct with python runtime 7",
),
("/restapis/normal/nodejsFunction", "Hello World from nodejs function construct 7"),
("/restapis/normal/functionNodeJsRuntime", "Hello World from function construct with nodejs runtime 7"),
("/restapis/normal/preBuiltFunctionNodeJsRuntime", "Hello World from nodejs pre built function 7"),
("/restapis/normal/goFunction", "Hello World from go function construct"),
("/restapis/normal/functionGoRuntime", "Hello World from function construct with go runtime"),
("/restapis/normal/dockerImageFunction", "Hello World from docker image function construct"),
("/restapis/normal/functionImageAsset", "Hello World from function construct with image asset"),
]
)
@pytest.mark.flaky(reruns=3)
@pytest.mark.timeout(timeout=1000, method="thread")
def test_invoke_api(self, url_suffix, expected_message):
response = requests.get(self.url + url_suffix, timeout=800)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.json().get("message"), expected_message)
Empty file.
6 changes: 6 additions & 0 deletions tests/iac_integration/cdk/testdata/cdk_v1/java/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"app": "mvn versions:use-latest-versions -DallowMajorUpdates=false && mvn -e -q compile exec:java",
"context": {

}
}
90 changes: 90 additions & 0 deletions tests/iac_integration/cdk/testdata/cdk_v1/java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<groupId>com.myorg</groupId>
<artifactId>java</artifactId>
<version>0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<includes>
<include>software.amazon.awscdk:*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>com.myorg.JavaApp</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<!-- AWS Cloud Development Kit -->
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>core</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>apigateway</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>apigatewayv2</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>apigatewayv2-integrations</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>lambda</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>lambda-go</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>lambda-nodejs</artifactId>
<version>1.120.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>lambda-python</artifactId>
<version>1.120.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.myorg;

import software.amazon.awscdk.core.App;
import software.amazon.awscdk.core.StackProps;

import java.util.Arrays;

public class JavaApp {
public static void main(final String[] args) {
App app = new App();

new JavaStack(app, "TestStack", StackProps.builder()
.build());

app.synth();
}
}
Loading