azure-sdk-for-js/common/smoke-test
Jeremy Meng b03348a145
[smoke-tests] skip overriding version for dependency not managed in this repo (#22532)
* [smoke-tests] skip overriding version for dependency not managed in this repo

`@azure/msal-node` is not managed in this repo, so we should keep the version
specified in package.json.

* Update common/smoke-test/Initialize-SmokeTests.ps1

Co-authored-by: Albert Cheng <38804567+ckairen@users.noreply.github.com>

Co-authored-by: Albert Cheng <38804567+ckairen@users.noreply.github.com>
2022-07-11 21:38:00 +00:00
..
test-cases [EngSys] prepare for upgrading TypeScript to v4.6 2022-04-19 12:11:57 -07:00
Initialize-SmokeTests.ps1 [smoke-tests] skip overriding version for dependency not managed in this repo (#22532) 2022-07-11 21:38:00 +00:00
README.md Rename hardcoded master links to use main 2021-06-22 15:51:16 -07:00
package.json Add Node 8 to smoke test matrix (#14623) 2021-04-22 10:43:37 -07:00
run.js [engsys] improve smoke test runner (#20872) 2022-03-30 10:54:46 -07:00
smoke-tests.yml Use base platform matrix for CI tests (#14647) 2021-04-05 12:49:49 -04:00

README.md

Azure SDK for JavaScript Smoke Test

The Smoke Tests validate customer scenarios by creating an application which uses package dependencies, loads all packages into a single process, and executes code samples to ensure basic end to end scenarios work as expected.

Smoke Tests are meant to be run periodically in an Azure DevOps pipeline. See smoke-tests.yml to configure Smoke Tests in an Azure DevOps pipeline. When run in an Azure DevOps pipeline specify the -CI flag to ensure environment variables are properly set and error/warning messages are properly surfaced during the execution.

Smoke Tests can be run locally to debug failures.

This Smoke Test tool automates the process of deploying resources, preparing, and executing samples.

Samples are opt-out and can be configured in the package.json file of the package.

Requirements

Configuring Samples

By default all JavaScript samples are prepped, loaded, and executed. Samples are assumed to work with just the environment variables defined in test-resources.json for the service. Samples which have additional resource requirements should opt out of execution.

To opt-out, set the value in the sdk/<service>/<package>/package.json.

To opt-out of all smoke tests:

  "//sampleConfiguration": {
    "skipFolder": true
  }

To opt-out particular files that will fail unnecessarily in tests (note files not skipped will be included in smoke tests):

  "//sampleConfiguration": {
    "skip": [
      "anonymousCred.js",
      "azureAdAuth.js",
      "basic.js",
      "customPipeline.js",
      "iterators.js",
      "sharedKeyCred.js"
    ]
  },

Running Smoke Tests

Initialize Smoke Tests

Run Initialize-SmokeTests.ps1 to deploy resources and prepare samples. The deploy script performs the following actions:

  1. Searches for packages that have samples.
  2. Deploys resource definitions specified in test-resources.json via Azure Resource Manager (via /eng/common/TestResources/New-TestResources.ps1).
  3. Preps samples to execute in the JS Smoke Test harness. This will take the form of dist-samples directories for included projects in sdk/.
  4. Updates the local directory package.json to include dependencies required by smoke tests.
  5. Generates the Smoke Test run manifest used by run.js, containing a list of smoke test directories to execute.

Omit the -CI flag when running locally to have environment variables set in the context of your current PowerShell session.

Use the -ServiceDirectory parameter to isolate testing to a single Service Directory (e.g. -ServiceDirectory appconfiguration)

In the folder common/smoke-tests/

.\Initialize-SmokeTests.ps1
  -TestApplicationId <test_application_aad_application_id> `
  -TestApplicationSecret <test_application_aad_secret>`
  -TestApplicationOid <test_application_service_principal_object_id> `
  -TenantId <tenant_id>`
  -SubscriptionId <subscription_id> `
  -ServiceDirectory <service_directory>

Run tests

In the folder common/smoke-test/

# Install generated dependencies for smoke-tests in run-manifest.json
npm i

# Run smoke tests defined in run-manifest.json
node run.js

NOTE: node run.js must be run from within the same powershell session that Initialize-SmokeTests.ps1 was run, since that script sets the NODE_PATH variable to the current directory (so that module imports from the samples will be redirected). To run node run.js from a separate session, set/export the NODE_PATH variable to the <current directory>/node_modules.