Skip to content
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

Review Testing Strategy for Instance Scheduler Module #8161

Closed
2 of 3 tasks
richgreen-moj opened this issue Oct 4, 2024 · 3 comments
Closed
2 of 3 tasks

Review Testing Strategy for Instance Scheduler Module #8161

richgreen-moj opened this issue Oct 4, 2024 · 3 comments
Assignees

Comments

@richgreen-moj
Copy link
Contributor

richgreen-moj commented Oct 4, 2024

User Story

As a MP Engineer
I expect the tests on the Instance Scheduler module to be representative of the environment that it will be run in
So that i have confidence when making changes/maintenance to the module

Value / Purpose

We recently made some maintenance updates to the container build in the instance scheduler module and the status checks/unit tests passed successfully.

We subsequently found that there was an issue with the container when it was run in the unit tests for the lambda function module as can be seen in this example

│ Error: invoking Lambda Function (instance-scheduler-lambda-function-114): {"errorType":"Runtime.ExitError","errorMessage":"RequestId: 075fdbb1-d817-42eb-a662-165f3f7f5610 Error: Runtime exited with error: exit status 127"}
│ 
│   with aws_lambda_invocation.test_invocation,
│   on main.tf line 152, in resource "aws_lambda_invocation" "test_invocation":
│  152: resource "aws_lambda_invocation" "test_invocation" {
│ 
╵}
    apply.go:15: 
        	Error Trace:	/home/runner/work/modernisation-platform-terraform-lambda-function/modernisation-platform-terraform-lambda-function/test/apply.go:15
        	            				/home/runner/work/modernisation-platform-terraform-lambda-function/modernisation-platform-terraform-lambda-function/test/module_test.go:20
        	Error:      	Received unexpected error:
        	            	FatalError{Underlying: error while running command: exit status 1; ╷
        	            	│ Error: invoking Lambda Function (instance-scheduler-lambda-function-114): {"errorType":"Runtime.ExitError","errorMessage":"RequestId: 075fdbb1-d817-42eb-a662-165f3f7f5610 Error: Runtime exited with error: exit status 127"}
        	            	│ 
        	            	│   with aws_lambda_invocation.test_invocation,
        	            	│   on main.tf line 152, in resource "aws_lambda_invocation" "test_invocation":
        	            	│  152: resource "aws_lambda_invocation" "test_invocation" {
        	            	│ 
        	            	╵}
        	Test:       	TestLambdaCreation

The purpose of this story is to investigate why the tests on the instance scheduler repo are not replicant of the ones in the lambda function module as the container build updates which were made caused the instance scheduler to fail the next time it was triggered.

Useful Contacts

@richgreen-moj @ASTRobinson @connormaglynn

Additional Information

No response

Definition of Done

  • Review testing strategy to see if any improvement can be made
  • Carry out any identified improvements
  • Update any documentation as required
@ASTRobinson
Copy link
Contributor

Following an investigation into several testing options—including creating new Go tests and adding a Lambda function unit test to replicate the initial failure cases (see test suite) - I found that the SAM CLI, already being used for build and validation, can also invoke AWS Lambda functions locally. This allowed us to leverage the SAM local invoke command for local Lambda testing.

Examples of SAM invoke tests:

A key issue I encountered was that GitHub Actions reports a successful exit code for the SAM CLI command even if the Lambda invocation fails (similar issue detailed here: GitHub issue). To address this, I implemented a workaround that captures the SAM output as a variable and checks for errors using grep.

@ASTRobinson
Copy link
Contributor

above PR merged in and checked tests are running correctly. moving over for review

@mikereiddigital
Copy link
Contributor

I've reviewed this and am happy it's complete.

@mikereiddigital mikereiddigital closed this as completed by moving to Done in Modernisation Platform Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants