Skip to content

Add smoke test to Lambda OCI images for TZData being available. #1636

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 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -71,6 +71,7 @@ public ImageFunctionTests()
[InlineData("ImageFunction::ImageFunction.Function::Ping", "ping", "pong")]
[InlineData("ImageFunction::ImageFunction.Function::HttpsWorksAsync", "", "SUCCESS")]
[InlineData("ImageFunction::ImageFunction.Function::VerifyLambdaContext", "", "SUCCESS")]
[InlineData("ImageFunction::ImageFunction.Function::VerifyTzData", "", "SUCCESS")]
public async Task SuccessfulTests(string handler, string input, string expectedResponse)
{
await UpdateHandlerAsync(handler);
Expand Down Expand Up @@ -170,6 +171,7 @@ await _lambdaClient.CreateFunctionAsync(new CreateFunctionRequest
MemorySize = 512,
Role = _executionRoleArn,
PackageType = PackageType.Image,
Timeout = 30,
Copy link
Member Author

@normj normj Dec 8, 2023

Choose a reason for hiding this comment

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

I added the timeout because the default value is 3 seconds and apparently listing all of the timezones at least for the first time can take longer then 3 seconds.

Architectures = new List<string> {GetArchitecture()}
});
break;
Expand Down
12 changes: 12 additions & 0 deletions LambdaRuntimeDockerfiles/SmokeTests/test/ImageFunction/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ public string VerifyLambdaContext(ILambdaContext lambdaContext)
return GetResponse(true);
}

// .NET on Linux uses the tzdata system package to get time zone information.
// If TzData is not installed/available in the Linux environment the
// TimeZoneInfo.GetSystemTimeZones() will return an empty collection.
// For futher information: https://github.com/aws/aws-lambda-dotnet/issues/1620
public string VerifyTzData(ILambdaContext lambdaContext)
{
AssertTrue(TimeZoneInfo.GetSystemTimeZones().Count > 0, "No time zones were found");
AssertNotNull(TimeZoneInfo.FindSystemTimeZoneById("Europe/London"), "Failed to find Europe/London timezone");

return SuccessResult;
}

#endregion

#region Private methods
Expand Down