-
Notifications
You must be signed in to change notification settings - Fork 251
Fix JavaLocalLambdaRunConfigurationIntegrationTest integ tests #4549
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
Changes from 52 commits
93f7afb
e461ac4
897d9f0
823b54c
82f471c
45e90e8
c03058f
6af9479
b720ba1
2ea0f42
6b7379e
c8e352f
dcf4c88
0da051f
6c6137c
f7af73e
8ddbc85
9fa1948
e934195
294b61b
f15e33e
d7f60a0
cdc67b0
f9e97d5
570c6ba
7f14384
2a06d8f
be59d68
4601fca
80167ef
b8d1547
69eec7d
bd3ce52
094f55c
8c4a7d1
9ef586a
51751a6
9ccfe1a
a334f2d
e666ce1
2436377
3da6809
c1b5951
341784e
5eb7e29
968ef56
78dbd55
9bd6e08
0fef2f6
8d3ca01
d2c098a
6afb57e
e28dca9
7966412
caacfef
7f82b2d
568b258
371b856
f1c5342
93c06ce
cd041d4
72495b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import software.aws.toolkits.core.utils.RuleUtils | |
import software.aws.toolkits.jetbrains.core.credentials.MockCredentialsManager | ||
import software.aws.toolkits.jetbrains.services.lambda.execution.local.createHandlerBasedRunConfiguration | ||
import software.aws.toolkits.jetbrains.services.lambda.execution.local.createTemplateRunConfiguration | ||
import software.aws.toolkits.jetbrains.services.lambda.sam.SamOptions | ||
import software.aws.toolkits.jetbrains.utils.addBreakpoint | ||
import software.aws.toolkits.jetbrains.utils.checkBreakPointHit | ||
import software.aws.toolkits.jetbrains.utils.executeRunConfigurationAndWait | ||
|
@@ -30,6 +31,8 @@ import software.aws.toolkits.jetbrains.utils.samImageRunDebugTest | |
import software.aws.toolkits.jetbrains.utils.setSamExecutableFromEnvironment | ||
import software.aws.toolkits.jetbrains.utils.setUpGradleProject | ||
import software.aws.toolkits.jetbrains.utils.setUpJdk | ||
import java.io.File | ||
import java.nio.file.Files | ||
|
||
@RunWith(Parameterized::class) | ||
class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: LambdaRuntime) { | ||
|
@@ -51,11 +54,11 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
private val mockId = "MockCredsId" | ||
private val mockCreds = AwsBasicCredentials.create("Access", "ItsASecret") | ||
private val input = RuleUtils.randomName() | ||
private val gradleUserHomeDir = Files.createTempDirectory("test-gradle-user-home").toAbsolutePath().toString() | ||
|
||
@Before | ||
fun setUp() { | ||
setSamExecutableFromEnvironment() | ||
|
||
val fixture = projectRule.fixture | ||
val module = fixture.addModule("main") | ||
val psiClass = fixture.addClass( | ||
|
@@ -95,6 +98,7 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
fun tearDown() { | ||
CompilerTestUtil.disableExternalCompiler(projectRule.project) | ||
MockCredentialsManager.getInstance().reset() | ||
File(gradleUserHomeDir).deleteRecursively() | ||
} | ||
|
||
@Test | ||
|
@@ -103,7 +107,9 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
project = projectRule.project, | ||
runtime = runtime.toSdkRuntime(), | ||
input = "\"Hello World\"", | ||
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this need to be mutable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted changes |
||
samOptions = SamOptions(buildInContainer = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain why we need to build in container? why would we want to do one over the other? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As expected, making it run in a containerized environment doesn't require env vars to be set The test case passed since container has its own grade user home dir. |
||
) | ||
assertThat(runConfiguration).isNotNull | ||
|
||
|
@@ -120,7 +126,9 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
runtime = runtime.toSdkRuntime(), | ||
input = projectRule.fixture.tempDirFixture.createFile("tmp", "\"Hello World\"").canonicalPath!!, | ||
inputIsFile = true, | ||
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
samOptions = SamOptions(buildInContainer = true) | ||
) | ||
assertThat(runConfiguration).isNotNull | ||
|
||
|
@@ -152,7 +160,9 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
templateFile = templateFile.containingFile.virtualFile.path, | ||
logicalId = "SomeFunction", | ||
input = "\"Hello World\"", | ||
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
samOptions = SamOptions(buildInContainer = true) | ||
) | ||
|
||
assertThat(runConfiguration).isNotNull | ||
|
@@ -185,7 +195,9 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
templateFile = templateFile.containingFile.virtualFile.path, | ||
logicalId = "SomeFunction", | ||
input = "\"Hello World\"", | ||
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
samOptions = SamOptions(buildInContainer = true) | ||
) | ||
|
||
assertThat(runConfiguration).isNotNull | ||
|
@@ -204,7 +216,9 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |
project = projectRule.project, | ||
runtime = runtime.toSdkRuntime(), | ||
input = "\"Hello World\"", | ||
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
samOptions = SamOptions(buildInContainer = true) | ||
) | ||
assertThat(runConfiguration).isNotNull | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,10 @@ | |
addParameter(buildDir.toString()) | ||
if (samOptions.buildInContainer) { | ||
withParameters("--use-container") | ||
environmentVariables.forEach { (key, value) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im not sure it's a good idea for the container environment to always inherit these |
||
withParameters("--container-env-var") | ||
withParameters("$key=$value") | ||
} | ||
Check warning on line 108 in plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamExecutable.kt
|
||
} | ||
|
||
if (samOptions.skipImagePull) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,11 @@ fun createTemplateRunConfiguration( | |
inputIsFile: Boolean = false, | ||
credentialsProviderId: String? = null, | ||
region: AwsRegion? = getDefaultRegion(), | ||
environmentVariables: MutableMap<String, String> = mutableMapOf(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does it need to be mutable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted these changes |
||
samOptions: SamOptions = SamOptions() | ||
): LocalLambdaRunConfiguration { | ||
val runConfiguration = samRunConfiguration(project) | ||
runConfiguration.environmentVariables(environmentVariables) | ||
runConfiguration.useTemplate(templateFile, logicalId) | ||
runConfiguration.isImage = isImage | ||
runConfiguration.runtime(runtime) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is in the temp directory, do we still need to cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted changes, since we doesn't required temp dir