Skip to content

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

Merged
merged 62 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
93f7afb
testing integ tests
vchikoti1998 Jun 5, 2024
e461ac4
add gradle user home
vchikoti1998 Jun 5, 2024
897d9f0
increased memory to 4gb
vchikoti1998 Jun 5, 2024
823b54c
deleting lock file if exists
vchikoti1998 Jun 5, 2024
82f471c
fix trimIndent
vchikoti1998 Jun 5, 2024
45e90e8
fix detekt
vchikoti1998 Jun 5, 2024
c03058f
setup gradle.properties to tst-project dir
vchikoti1998 Jun 5, 2024
6af9479
test
vchikoti1998 Jun 5, 2024
b720ba1
tst
vchikoti1998 Jun 6, 2024
2ea0f42
tst with module main path
vchikoti1998 Jun 6, 2024
6b7379e
set property Gradle_user_home
vchikoti1998 Jun 6, 2024
c8e352f
set env var for specific lambda runConfig
vchikoti1998 Jun 6, 2024
dcf4c88
created a tem folder
vchikoti1998 Jun 7, 2024
0da051f
tst
vchikoti1998 Jun 11, 2024
6c6137c
temp
vchikoti1998 Jun 12, 2024
f7af73e
envVar in SamBuildLambda
vchikoti1998 Jun 12, 2024
8ddbc85
testing
vchikoti1998 Jun 12, 2024
9fa1948
Memory size bumped
vchikoti1998 Jun 12, 2024
e934195
cleanUp folder
vchikoti1998 Jun 13, 2024
294b61b
add sleep
vchikoti1998 Jun 13, 2024
f15e33e
removed sleep
vchikoti1998 Jun 13, 2024
d7f60a0
inclue stacktrace
vchikoti1998 Jun 13, 2024
cdc67b0
revert stacktrace
vchikoti1998 Jun 13, 2024
f9e97d5
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 13, 2024
570c6ba
stacktrace for integTests
vchikoti1998 Jun 13, 2024
7f14384
set maxHeapSize
vchikoti1998 Jun 13, 2024
2a06d8f
tst debug
vchikoti1998 Jun 13, 2024
be59d68
revert heapSize
vchikoti1998 Jun 14, 2024
4601fca
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 14, 2024
80167ef
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 14, 2024
b8d1547
test maxheapsize
vchikoti1998 Jun 14, 2024
69eec7d
revert maxheap
vchikoti1998 Jun 15, 2024
bd3ce52
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 15, 2024
094f55c
tst memeory leaks
vchikoti1998 Jun 15, 2024
8c4a7d1
tst rider memory leaks
vchikoti1998 Jun 15, 2024
9ef586a
tst
vchikoti1998 Jun 15, 2024
51751a6
revert deploy and upload integs ignore
vchikoti1998 Jun 15, 2024
9ccfe1a
revert python localLAmbda integ ignore
vchikoti1998 Jun 15, 2024
a334f2d
removed ignore for riderInteg
vchikoti1998 Jun 15, 2024
e666ce1
delete sln file after test
vchikoti1998 Jun 16, 2024
2436377
test
vchikoti1998 Jun 16, 2024
3da6809
test
vchikoti1998 Jun 16, 2024
c1b5951
set env var
vchikoti1998 Jun 16, 2024
341784e
stacktrace for linuxIntegs
vchikoti1998 Jun 17, 2024
5eb7e29
cleanUp tempdir
vchikoti1998 Jun 17, 2024
968ef56
cleanUp code
vchikoti1998 Jun 17, 2024
78dbd55
addressed feedback
vchikoti1998 Jun 18, 2024
9bd6e08
remove @afterclass in src
vchikoti1998 Jun 18, 2024
0fef2f6
test
vchikoti1998 Jun 18, 2024
8d3ca01
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 19, 2024
d2c098a
add sam build option flag
vchikoti1998 Jun 20, 2024
6afb57e
revert test case samExecuableTest
vchikoti1998 Jun 20, 2024
e28dca9
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 23, 2024
7966412
comment out for test
vchikoti1998 Jun 23, 2024
caacfef
changes reverted
vchikoti1998 Jun 24, 2024
7f82b2d
set env var in runconfig
vchikoti1998 Jun 28, 2024
568b258
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jun 28, 2024
371b856
added buildInContainer
vchikoti1998 Jul 1, 2024
f1c5342
removed env map
vchikoti1998 Jul 1, 2024
93c06ce
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jul 8, 2024
cd041d4
add comment
vchikoti1998 Jul 8, 2024
72495b2
Merge branch 'main' into vchikoti/javaLocalLambdaRunConfigInteg_Test
vchikoti1998 Jul 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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(
Expand Down Expand Up @@ -95,6 +98,7 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda
fun tearDown() {
CompilerTestUtil.disableExternalCompiler(projectRule.project)
MockCredentialsManager.getInstance().reset()
File(gradleUserHomeDir).deleteRecursively()
Copy link
Contributor

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?

Copy link
Contributor Author

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

}

@Test
Expand All @@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be mutable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted changes

samOptions = SamOptions(buildInContainer = true)
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
addParameter(buildDir.toString())
if (samOptions.buildInContainer) {
withParameters("--use-container")
environmentVariables.forEach { (key, value) ->
Copy link
Contributor

Choose a reason for hiding this comment

The 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

View check run for this annotation

Codecov / codecov/patch

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamExecutable.kt#L106-L108

Added lines #L106 - L108 were not covered by tests
}

if (samOptions.skipImagePull) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BuildLambda(private val request: BuildLambdaRequest) : SamCliStep() {
override val stepName: String = message("lambda.create.step.build")

override fun constructCommandLine(context: Context): GeneralCommandLine = getCli().samBuildCommand(

templatePath = request.templatePath,
logicalId = request.logicalId,
buildDir = request.buildDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ fun createTemplateRunConfiguration(
inputIsFile: Boolean = false,
credentialsProviderId: String? = null,
region: AwsRegion? = getDefaultRegion(),
environmentVariables: MutableMap<String, String> = mutableMapOf(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does it need to be mutable

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Expand Down
Loading