-
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
Fix JavaLocalLambdaRunConfigurationIntegrationTest integ tests #4549
Conversation
/runIntegrationTest |
gradle.properties
Outdated
@@ -18,7 +18,7 @@ kotlin.code.style=official | |||
# Gradle settings | |||
org.gradle.parallel=true | |||
org.gradle.caching=true | |||
org.gradle.jvmargs=-Xmx2048m | |||
org.gradle.jvmargs=-Xmx4096m |
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.
why do we need this?
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.
modified for testing, may be this is an issue, but it doesn't appear to be.
reverting this change
} | ||
|
||
private fun createGradlePropertiesFile(gradleUserHome: File) { | ||
val gradlePropertiesFile = File(gradleUserHome, "gradle.properties") |
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.
shouldn't this be the project root? how would a gradle instance discover this location if the configuration is self-referential with nothing outside referencing it?
gradlePropertiesFile.writeText( | ||
""" | ||
org.gradle.jvmargs=-Xmx4096m | ||
gradle.user.home=${gradleUserHome.absolutePath} |
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.
something that is also unclear at the moment is if we are actually allowed to modify the user home in this manner, or if this is too late because gradle has already selected a user home
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.
So, in this case shall we try using Env Variable GRADLE_USER_HOME, so it can be set before Gradle initializes.
will test this out
/retryBuilds |
This is rider IntegrationTest error:
will work on separate PR |
@@ -4,13 +4,16 @@ | |||
package software.aws.toolkits.jetbrains.services.lambda.steps | |||
|
|||
import com.intellij.execution.configurations.GeneralCommandLine | |||
import org.junit.AfterClass |
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.
this code is in the src
tree, which generally means it is not appropriate to reference any libraries that are used in tests. in an upcoming PR, we pull in some build system improvements that remove a lot of test libraries from the classpath, which will make this harder to do
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.
sure, will provide in the test class
@@ -24,12 +27,14 @@ data class BuildLambdaRequest( | |||
|
|||
class BuildLambda(private val request: BuildLambdaRequest) : SamCliStep() { | |||
override val stepName: String = message("lambda.create.step.build") | |||
private val buildEnvVars = mapOf("GRADLE_USER_HOME" to gradleUserHomeDir) |
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.
i dont think we always want to set the Gradle home directory to a temp directory. this should only be set if configured by a test
as discussed offline:
|
@@ -95,6 +98,7 @@ class JavaLocalLambdaRunConfigurationIntegrationTest(private val runtime: Lambda | |||
fun tearDown() { | |||
CompilerTestUtil.disableExternalCompiler(projectRule.project) | |||
MockCredentialsManager.getInstance().reset() | |||
File(gradleUserHomeDir).deleteRecursively() |
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
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted changes
credentialsProviderId = mockId | ||
credentialsProviderId = mockId, | ||
environmentVariables = mutableMapOf("GRADLE_USER_HOME" to gradleUserHomeDir), | ||
samOptions = SamOptions(buildInContainer = true) |
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.
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 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.
@@ -102,6 +102,10 @@ fun GeneralCommandLine.samBuildCommand( | |||
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 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
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted these changes
Building in a container ensures the build environment matches the AWS Lambda runtime, reducing runtime errors and improving deployment consistency. This is essential when local runtimes or dependencies differ from those required by Lambda. In addition, containerized builds can provide isolated environments that avoid conflicts with other local dependencies or configurations. |
|
Types of changes
Description
The gradle instance in the test should be configured to use a different user home than the instance of gradle running the test
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.