Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

test: Split integration and E2E tests for AppStream/NonAppStream #663

Merged
2 changes: 2 additions & 0 deletions main/end-to-end-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ To run the E2E tests, you will need the following items:
- A project set up for that researcher that can launch EC2 workspaces and Sagemaker workspaces
- A configured EC2 workspace
- A configured Sagemaker workspace
- An organization study in which the researcher has Admin permission to
- An organization study in which the research doesn't have Admin permission to

Once you've confirmed that you have the items above setup, you can create a `cypress.dev.json` and a `cypress.local.json` file with the configurations needed for your tests. You can use `cypress.json` as a template for your new configuration files. An example file is included as `cypress.local.example.json`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
describe('Sample AppStream test', () => {
it('', () => {
cy.visit('/');
});
});
144 changes: 0 additions & 144 deletions main/end-to-end-tests/cypress/integration/workspaces.appstream.spec.js

This file was deleted.

9 changes: 6 additions & 3 deletions main/end-to-end-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
"scripts": {
"cypress:open:local": "cypress open -C cypress.local.json",
"cypress:open:dev": "cypress open -C cypress.dev.json",
"cypress:run-tests:local": "cypress run -C cypress.local.json",
"cypress:run-tests:dev": "cypress run -C cypress.dev.json",
"cypress:run-tests:github": "cypress run -C cypress.github.json"
"cypress:run-tests:local": "cypress run -C cypress.local.json --spec cypress/integration/{common,appstream-egress-disabled}/*",
"cypress:run-tests:local:appstream-egress-enabled": "cypress run -C cypress.local.json --spec cypress/integration/{common,appstream-egress-enabled}/*",
"cypress:run-tests:dev": "cypress run -C cypress.dev.json --spec cypress/integration/{common,appstream-egress-disabled}/*",
"cypress:run-tests:dev:appstream-egress-enabled": "cypress run -C cypress.dev.json --spec cypress/integration/{common,appstream-egress-enabled}/*",
"cypress:run-tests:github": "cypress run -C cypress.github.json --spec cypress/integration/{common,appstream-egress-disabled}/*",
"cypress:run-tests:github:appstream-egress-enabled": "cypress run -C cypress.github.json --spec cypress/integration/{common,appstream-egress-enabled}/*"
},
"husky": {
"hooks": {
Expand Down
19 changes: 17 additions & 2 deletions main/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The integration-tests package is for running API tests against all SWB APIs.
These tests can run against local and dev environments during development.
They can also be configured to run automatically as part of a GitHub workflow or CI/CD pipeline.


## Prerequisites

### Test Resources
Expand All @@ -16,6 +17,7 @@ To run integration tests, the following resources need to be created in advance:

* **Test Administrator:** Create an internal admin-role user for running integration tests. (**Note the username and password**)


* **Test Project:** Create a default project for running integration tests. (**Note the projectId**)

* **AWS Budget:** Create a budget for the AWS account associated with the Test Project.
Expand All @@ -34,6 +36,7 @@ Use the same `<STAGE>` name as the main config file in `/main/config/settings`.
Use Test Admin username, projectId, and Parameter Store name noted from the [Test Resources](#test-resources) section for field username, passwordPath and projectId in the config file.
Use the same config values used in `/main/config/settings` for fields awsRegion, awsProfile, solutionName, envName, ane envType.


**Note**

This file is unique from other `<STAGE>.yml` files under other SDCs. It does not gather serverless settings passed on from the hierarchies above (eg. from `main/config/settings/.defaults.yml`)
Expand All @@ -45,22 +48,32 @@ Once test resources and config file are created, you can run the integration tes
Note: Integration tests will create resources in the environment they are executed against.

### Run against dev environment

- In config file `main/integration-tests/config/settings/<STAGE>.yml`
- set `isBuildServer` to `false`
- set `isLocal` to `false`

##### run all integration tests from the root directory with:

Run AppStream tests. AppStream and Egress should be enabled in the testing environment
```bash
$ scripts/run-integration-tests.sh <STAGE> AppStream
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we include egress in the stage- AppStreamEgressEnabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

```

Run non AppStream tests
```bash
$ scripts/run-integration-tests.sh <STAGE>
```

Run specific test suites under `main/integration-tests` with:

```bash
$ pnpm intTest __test__/api-tests/<your test suite file> -- --stage=<STAGE>
$ pnpm intTestSpecific __test__/api-tests/<your test suite file> -- --stage=<STAGE>
# IMPORTANT: notice the additional '-- ' in front of the '--stage='
```

### Run against local deployment (SLS Offline)

- In config file `main/integration-tests/config/settings/<STAGE>.yml`
- set `isBuildServer` to `false`
- set `isLocal` to `true`
Expand All @@ -69,6 +82,7 @@ $ pnpm intTest __test__/api-tests/<your test suite file> -- --stage=<STAGE>
- Trigger integration tests with the same [commands](#run-all-integration-tests-from-the-root-directory-with)

### Run in CI/CD Pipeline

- In config file `main/integration-tests/config/settings/<STAGE>.yml`
- set `isBuildServer` to `true`
- set `isLocal` to `false`
Expand All @@ -78,6 +92,7 @@ $ pnpm intTest __test__/api-tests/<your test suite file> -- --stage=<STAGE>
- Integration test will be triggered as part of the CI/CD pipeline

### Run in GitHub Workflow

- In config file `main/integration-tests/config/settings/<STAGE>.yml`
- set `isBuildServer` to `true`
- set `isLocal` to `false`
Expand All @@ -86,4 +101,4 @@ $ pnpm intTest __test__/api-tests/<your test suite file> -- --stage=<STAGE>
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- DEPLOYMENT_BUCKET (set the value to `<namespace>-artifacts`)
- Integration test will be triggered as part of a GitHub workflow
- Integration test will be triggered as part of a GitHub workflow
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../support/setup');
const errorCode = require('../../../support/utils/error-code');
const { runSetup } = require('../../../../support/setup');
const errorCode = require('../../../../support/utils/error-code');

describe('Get data source accounts scenarios', () => {
let setup;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../../support/setup');

describe('Register data source study scenarios', () => {
let setup;
let adminSession;
let accountId;
let bucketName;

beforeAll(async () => {
setup = await runSetup();
adminSession = await setup.defaultAdminSession();

// We register an account to be used by all the tests in this test suite
accountId = setup.gen.accountId();
await adminSession.resources.dataSources.accounts.create({ id: accountId });

// We register a bucket to be used by all the tests in this test suite
bucketName = setup.gen.string({ prefix: 'ds-bucket-test' });
await adminSession.resources.dataSources.accounts
.account(accountId)
.buckets()
.create({ name: bucketName });
});

afterAll(async () => {
await setup.cleanup();
});

describe('Registering a data source study', () => {
it('should return study registration information if admin', async () => {
const admin2Session = await setup.createAdminSession();
const id = setup.gen.string({ prefix: 'ds-study-id-test' });
const study = {
id,
adminUsers: [admin2Session.user.uid],
};

await expect(
admin2Session.resources.dataSources.accounts
.account(accountId)
.buckets()
.bucket(bucketName)
.studies()
.create(study),
).resolves.toMatchObject({ id, accountId, bucket: bucketName });
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../support/setup');
const errorCode = require('../../../support/utils/error-code');
const { runSetup } = require('../../../../support/setup');
const errorCode = require('../../../../support/utils/error-code');

describe('Create study scenarios', () => {
let setup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../support/setup');
const errorCode = require('../../../support/utils/error-code');
const { runSetup } = require('../../../../support/setup');
const errorCode = require('../../../../support/utils/error-code');

describe('List study scenarios', () => {
let setup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../support/setup');
const errorCode = require('../../../support/utils/error-code');
const { runSetup } = require('../../../../support/setup');
const errorCode = require('../../../../support/utils/error-code');

describe('List study files scenarios', () => {
let setup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* permissions and limitations under the License.
*/

const { runSetup } = require('../../../support/setup');
const errorCode = require('../../../support/utils/error-code');
const { runSetup } = require('../../../../support/setup');
const errorCode = require('../../../../support/utils/error-code');

describe('Get study permissions scenarios', () => {
let setup;
Expand Down
Loading