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

(aws/lambda): Lambda functional tests #9760

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
@@ -0,0 +1,35 @@
[
{
"name": "aws-cy-test",
"accountId": "123456789012",
"type": "aws",
"requiredGroupMembership": [],
"permissions": {},
"accountType": "aws-cy-test",
"environment": "aws-cy-test",
"challengeDestructiveActions": false,
"primaryAccount": false,
"cloudProvider": "aws",
"regions": [
{
"availabilityZones": ["us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d"],
"deprecated": false,
"name": "us-west-2",
"preferredZones": ["us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d"]
}
],
"eddaEnabled": false,
"sessionName": "Spinnaker",
"front50Enabled": false,
"assumeRole": "role/cypress",
"enabled": true,
"defaultKeyPair": "{{\"{{\"}}name{{\"}}\"}}-keypair",
"lifecycleHooks": [],
"discoveryEnabled": false,
"shieldEnabled": false,
"lambdaEnabled": true,
"allowPrivateThirdPartyImages": false,
"bastionEnabled": false,
"authorized": true
}
]
14 changes: 14 additions & 0 deletions test/functional/cypress/fixtures/lambda/functions/expand.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "lambdait",
"attributes": {
"name": "lambdait",
"email": "[email protected]",
"updateTs": "1631113788000",
"lastModifiedBy": "anonymous",
"cloudProviders": "aws",
"trafficGuards": [],
"instancePort": 80,
"user": "[anonymous]"
},
"clusters": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"account": "aws-cy-test",
"aliasConfigurations": [],
"code": {
"location": "https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/",
"repositoryType": "S3"
},
"codeSha256": "1IEet62p1BQ6LOxzRc6lqd1QkRxVRlx5+qe12eqe1+B0=",
"codeSize": 713959,
"description": "",
"environment": { "variables": {} },
"eventSourceMappings": [],
"fileSystemConfigs": [],
"functionArn": "arn:aws:lambda:us-west-2:123456789012:function:lambdait-java-integration-test",
"functionName": "lambdait-java-integration-test",
"handler": "io.armory.lambda.WelcomeLambda::handleRequest",
"lastModified": "2021-10-14T05:26:12.183+0000",
"lastUpdateStatus": "Successful",
"layers": [],
"memorySize": 128,
"packageType": "Zip",
"region": "us-west-2",
"revisionId": "412adcc7-000a-4d6c-ba56-1e25bbd18f89",
"revisions": { "412adcc7-000a-4d6c-ba56-1e25bbd18f89": "$LATEST", "faebbe11-7658-4fbf-b1d1-ae0538db1fd3": "14" },
"role": "arn:aws:iam::123456789012:role/CypressLambda",
"runtime": "java8",
"state": "Active",
"tags": {},
"targetGroups": [],
"timeout": 3,
"tracingConfig": { "mode": "PassThrough" },
"version": "$LATEST",
"vpcConfig": { "securityGroupIds": [], "subnetIds": [], "vpcId": "" }
}
]
10 changes: 10 additions & 0 deletions test/functional/cypress/fixtures/lambda/functions/networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account": "aws-cy-test",
"cloudProvider": "aws",
"deprecated": false,
"id": "vpc-a1234567",
"name": "default",
"region": "us-west-2"
}
]
16 changes: 16 additions & 0 deletions test/functional/cypress/fixtures/lambda/functions/subnets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"account": "aws-cy-test",
"accountId": "123456789012",
"availabilityZone": "us-west-2a",
"availableIpAddressCount": 250,
"cidrBlock": "10.0.60.0/24",
"deprecated": false,
"id": "subnet-123456789012",
"purpose": "cypress-subnet",
"region": "us-west-2",
"state": "available",
"type": "aws",
"vpcId": "vpc-123456789012"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "n/a",
"created": 1461949989729
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('Amazon ECS: aws-prod-ecsdemo cluster', () => {
);
cy.route('/instances/ecs-my-aws-devel-acct/us-west-2/f8757e00-184d-4288-b535-4124a739e7be',
'fixture:ecs/clusters/serverGroups.json');
cy.route('/applications/ecsapp/functions', []);
});

it('shows stored ECS cluster with their sequences', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('amazon ecs: ECSApp Server Group', () => {
'/applications/ecsapp/serverGroups/**/aws-prod-ecsdemo-v000?includeDetails=false',
'fixture:ecs/clusters/serverGroup.ecsdemo-v000.json',
);
cy.route('/applications/ecsapp/functions', []);
});

it('configure a new server group with artifacts', () => {
Expand Down
124 changes: 124 additions & 0 deletions test/functional/cypress/integration/lambda/functions_list_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { registerDefaultFixtures } from '../../support';

describe('Amazon Lambda: Lambda functions test', () => {
beforeEach(() => {
registerDefaultFixtures();
cy.route('/applications/lambdait/functions', 'fixture:lambda/functions/functions_list.json');
cy.route('/applications/lambdait?expand=false', 'fixture:lambda/functions/expand.json');
cy.route(
'/functions?account=aws-cy-test&functionName=lambdait-java-integration-test&provider=aws&region=us-west-2',
'fixture:lambda/functions/functions_list.json',
);
cy.route('/credentials?expand=true', 'fixture:lambda/functions/credentials_expand.json');
cy.route('/networks/aws', 'fixture:lambda/functions/networks.json');
cy.route('/subnets/aws', 'fixture:lambda/functions/subnets.json');
});

it('shows the Lambda funtions list and details', () => {
cy.viewport(1536, 960);
cy.visit('#/applications/lambdait/functions');

//Get the first lambda function on the list
cy.get('h6.clickable').first().click().should('exist');
cy.get('#function-actions-dropdown').contains('Function Actions').should('exist');
//Check the details
cy.get('h4.collapsible-heading')
.should(($h) => {
expect($h).to.contain('Function Details');
})
.click();
cy.get('.content-body').find('dt').contains('Last Modified').should('exist');
});

it('Create Lambda function', () => {
cy.viewport(1536, 960);
cy.visit('#/applications/lambdait/functions');
cy.get('.application-actions')
.find('button')
.should(($b) => {
expect($b).to.contain('Create Function');
})
.click();
cy.get('h4.modal-title').contains('Create New Function').should('exist');
//Fill Create Function modal
cy.get('[name="functionName"]').type('cypress-funtion-test');
cy.get('[name="s3bucket"]').type('s3-staging');
cy.get('[name="s3key"]').type('dev/lambdatest/lambda-0.0.1-SNAPSHOT.jar');
cy.get('[name="handler"]').type('io.WelcomeLambda::handleRequest');
cy.get('[name="publish"]').check();
cy.get('.TextInput[placeholder="Enter role ARN"]').type('arn:aws:iam::123456789012:role/SpinnakerAWSLambda');
cy.get('button.btn.btn-block.btn-sm.add-new').each((item, index, list) => {
item.click();
});
cy.get('tr.MapPair')
.children('td')
.find('input.form-control.input.input-sm')
.each((item, index, list) => {
cy.wrap(item).type('testing-' + index);
});
cy.get('input.TextInput[name="description"]').type('Cypress Testing');
cy.get('input.TextInput[name="targetGroups"]').type('test-tg');
cy.get('input.TextInput[name="deadLetterConfig.targetArn"]').type('arn:aws:lambda::123456789012:targetARN');
cy.get('.modal-footer').first().contains('Cancel').click();
});

it('Edit Lambda funtion', () => {
cy.viewport(1536, 960);
cy.visit('#/applications/lambdait/functions');

//Get the first lambda function on the list
cy.get('h6.clickable').first().click().should('exist');
cy.get('#function-actions-dropdown').contains('Function Actions').should('exist');
//Check the details
cy.get('h4.collapsible-heading')
.should(($h) => {
expect($h).to.contain('Function Details');
})
.click();
cy.get('.content-body').find('dt').contains('Last Modified').should('exist');

//Edit Lambda
cy.get('#function-actions-dropdown').click();
cy.get('[aria-labelledby="function-actions-dropdown"]').children().should('have.length', 2);
cy.get('[aria-labelledby="function-actions-dropdown"]').contains('Edit').click();
cy.get('h4.modal-title').contains('Edit').should('exist');
cy.get('[name="s3bucket"]').type('s3-staging');
cy.get('[name="s3key"]').type('dev/lambdatest/lambda-0.0.1-SNAPSHOT.jar');
cy.get('[name="publish"]').check();
cy.get('button.btn.btn-block.btn-sm.add-new').each((item, index, list) => {
item.click();
});
cy.get('tr.MapPair')
.children('td')
.find('input.form-control.input.input-sm')
.each((item, index, list) => {
cy.wrap(item).type('testing-' + index);
});
cy.get('input.TextInput[name="description"]').type('Cypress Testing');
cy.get('input.TextInput[name="targetGroups"]').type('test-tg');
cy.get('input.TextInput[name="deadLetterConfig.targetArn"]').type('arn:aws:lambda::123456789012:targetARN');
cy.get('.modal-footer').first().contains('Cancel').click();
});

it('shows the Lambda funtions list', () => {
cy.viewport(1536, 960);
cy.visit('#/applications/lambdait/functions');

//Get the first lambda function on the list
cy.get('h6.clickable').first().click().should('exist');
cy.get('#function-actions-dropdown').contains('Function Actions').should('exist');
//Check the details
cy.get('h4.collapsible-heading')
.should(($h) => {
expect($h).to.contain('Function Details');
})
.click();
cy.get('.content-body').find('dt').contains('Last Modified').should('exist');

//Delete Lambda
cy.get('#function-actions-dropdown').click();
cy.get('[aria-labelledby="function-actions-dropdown"]').contains('Delete').click();
cy.get('h4.modal-title').contains('Really delete').should('exist');
cy.get('.modal-footer').first().contains('Cancel').click();
});
});
Empty file.
2 changes: 1 addition & 1 deletion test/functional/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts:comment": "These scripts expect that Deck is built ('yarn build' from the root package)",
"scripts": {
"build": "cd ../../ && npm run build",
"build": "cd ../../ && export FUNCTIONS_ENABLED=true && npm run build",
"start": "cypress-runner open --nospa --path ../../build/webpack",
"test": "cypress-runner run --nospa --path ../../build/webpack",
"open": "npm run start"
Expand Down