Skip to content
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
2 changes: 1 addition & 1 deletion packages/dds/map/src/test/memory/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
"require": ["@fluid-internal/mocha-test-setup"],
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
"timeout": "60000",
};
2 changes: 1 addition & 1 deletion packages/dds/matrix/src/test/memory/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
"require": ["@fluid-internal/mocha-test-setup"],
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
"timeout": "90000",
};
2 changes: 1 addition & 1 deletion packages/dds/matrix/src/test/time/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
"node-option": ["expose-gc", "gc-global", "unhandled-rejections=strict"], // without leading "--"
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
"require": ["@fluid-internal/mocha-test-setup"],
"spec": ["dist/test/time/**/*.spec.*js", "--perfMode"],
"timeout": "15000",
};
2 changes: 1 addition & 1 deletion packages/dds/sequence/src/test/memory/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
"require": ["node_modules/@fluid-internal/mocha-test-setup"],
"require": ["@fluid-internal/mocha-test-setup"],
"spec": ["dist/test/memory/**/*.spec.*js", "--perfMode"],
"timeout": "60000",
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const newConfig = {
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"reporterOptions": ["reportDir=.memoryTestsOutput/"],
"require": [...config.require, "node_modules/@fluid-internal/mocha-test-setup"],
"require": [...config.require, "@fluid-internal/mocha-test-setup"],
"spec": [
"lib/test/benchmark/**/*.memory.spec.*js",
"lib/test/benchmark/**/*.all.spec.*js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const newConfig = {
"recursive": true,
"reporter": "@fluid-tools/benchmark/dist/MochaReporter.js",
"reporterOptions": ["reportDir=.timeTestsOutput/"],
"require": [...config.require, "node_modules/@fluid-internal/mocha-test-setup"],
"require": [...config.require, "@fluid-internal/mocha-test-setup"],
"spec": [
"lib/test/benchmark/**/*.time.spec.*js",
"lib/test/benchmark/**/*.all.spec.*js",
Expand Down
60 changes: 60 additions & 0 deletions tools/pipelines/templates/include-copy-dev-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) Microsoft Corporation and contributors. All rights reserved.
# Licensed under the MIT License.

# Copy runtime devDependencies from an installed package to somewhere else (usually the root package in the workspace)
# and install them.
# This is useful for test workloads that don't run in the original context of the package (i.e. that need to install it)
# such as the performance benchmarks and e2e test pipelines.

parameters:
- name: sourcePackageLocation
type: string

- name: destPackageLocation
type: string

steps:
# The test workload we are running frequently depends on devDependencies of the package being installed.
# To make sure these are available, copy them to the root package.json and reinstall.
- task: Bash@3
displayName: Copy devDependencies
inputs:
targetType: 'inline'
script: |
set -eu -o pipefail

testPkgJsonPath=${{ parameters.sourcePackageLocation }}/package.json
pkgJsonPath=${{ parameters.destPackageLocation }}/package.json
node -e "
const { devDependencies } = require('$testPkgJsonPath');
const pkg = require('$pkgJsonPath');
if (!pkg.devDependencies) {
pkg.devDependencies = {};
}
// Avoid copying some common dev dependencies that should only be required at build time.
// Keeping the dependency tree small helps reduce job time and likelihood of install failures, since
// dependencies added as part of this step won't be reproducible via pnpm-lock.
const avoidCopying = new Set([
'@types/node',
'typescript',
'@microsoft/api-extractor',
'@fluid-tools/build-cli',
'@fluidframework/build-common',
'@fluidframework/build-tools'
]);
for (const [k, v] of Object.entries(devDependencies)) {
if (!pkg.devDependencies[k] && !avoidCopying.has(k)) {
// Note that if you use string interpolation, bash interpreting the dollar sign takes precedence.
console.log('Adding devDependency ' + k + '@' + v);
pkg.devDependencies[k] = v;
}
}
require('fs').writeFileSync('$pkgJsonPath', JSON.stringify(pkg));
"

- task: Bash@3
displayName: 'pnpm install - extra dependencies for test files'
retryCountOnTaskFailure: 10
inputs:
targetType: 'inline'
script: 'pnpm install --no-frozen-lockfile'
10 changes: 10 additions & 0 deletions tools/pipelines/templates/include-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ parameters:
- name: packageManagerInstallCommand
type: string

- name: primaryRegistry
type: string
default: $(ado-feeds-primary-registry)

- name: userNpmrcPath
type: string
default: $(Agent.TempDirectory)/.npmrc

steps:
- ${{ if eq(parameters.packageManager, 'pnpm') }}:
- template: /tools/pipelines/templates/include-install-pnpm.yml@self
parameters:
buildDirectory: ${{ parameters.buildDirectory }}
primaryRegistry: ${{ parameters.primaryRegistry }}
userNpmrcPath: ${{ parameters.userNpmrcPath }}

- task: Bash@3
displayName: Install dependencies
Expand Down
11 changes: 5 additions & 6 deletions tools/pipelines/templates/include-setup-npmrc-for-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

parameters:
# Location for the .npmrc file.
# NOTE: Do not override the default value. It's a parameter just for reusability.
- name: npmrcLocation
- name: userNpmrcDirectory
type: string
default: $(Agent.TempDirectory)/global-download-npmrc

Expand Down Expand Up @@ -43,8 +42,8 @@ steps:
script: |
set -eu -o pipefail

mkdir -p ${{ parameters.npmrcLocation }}
cd ${{ parameters.npmrcLocation }}
mkdir -p ${{ parameters.userNpmrcDirectory }}
cd ${{ parameters.userNpmrcDirectory }}

echo "Generating .npmrc"

Expand All @@ -57,14 +56,14 @@ steps:
displayName: 'Authenticate to internal ADO feeds'
retryCountOnTaskFailure: 1
inputs:
workingFile: ${{ parameters.npmrcLocation }}/.npmrc
workingFile: ${{ parameters.userNpmrcDirectory }}/.npmrc

- task: Bash@3
displayName: Use the authenticated .npmrc file globally
inputs:
targetType: 'inline'
script: |
TARGET_FILE=${{ parameters.npmrcLocation }}/.npmrc
TARGET_FILE=${{ parameters.userNpmrcDirectory }}/.npmrc

# Configure the copied file to be the default user-level .npmrc file, so all invocations of npm use it.
# Particularly relevant for the ones that occur when we install older version for compat tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ steps:
ls -1 $TEST_PACKAGE_PATH_PATTERN

if [[ `ls -1 $TEST_PACKAGE_PATH_PATTERN | wc -l` -eq 1 ]]; then
npm install $(ls $TEST_PACKAGE_PATH_PATTERN)
pnpm install $(ls $TEST_PACKAGE_PATH_PATTERN)
else
echo "##vso[task.logissue type=error]Test package '${{ parameters.testPackageName }}' not found, or more than one possible match found. See messages above."
exit -1
Expand Down
50 changes: 17 additions & 33 deletions tools/pipelines/templates/include-test-perf-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,22 @@ parameters:
- name: artifactBuildId
type: string

# Path where the packages with perf tests will be installed.
# The template will create it, and install aria-logger in it.
- name: testWorkspace
type: string

# Path to the folder where the test files artifact should be downloaded.
- name: testFilesPath
type: string

# Path where the telemetry-generator package should be installed.
# It should be an empty directory so that it doesn't interfere with anything else.
# The caller of this template will need to know this in order to point to the correct locations for the handlers,
# which will be under <this path>/node_modules/@ff-internal/telemetry-generator/dist/handlers/.
- name: pathForTelemetryGeneratorInstall
type: string

# Name of the service that the tests are running against.
- name: endpointName
type: string
default: ''

- name: userNpmrcDirectory
type: string
default: $(Agent.TempDirectory)

steps:
- checkout: git://internal/ff_pipeline_host

- task: Bash@3
displayName: Print parameter/variable values for troubleshooting
inputs:
Expand All @@ -48,17 +42,24 @@ steps:
artifactBuildId=${{ parameters.artifactBuildId }}
artifactPipeline=${{ parameters.artifactPipeline }}
testFilesPath=${{ parameters.testFilesPath }}
testWorkspace=${{ parameters.testWorkspace }}

Build Params
SourceBranch=$(Build.SourceBranch)
"

# Note: there is some duplication between the .npmrc setup here, the pnpm configuration in the next step, and the
# base .npmrc file in ff_pipeline_host which could be cleaned up.
- template: /tools/pipelines/templates/include-setup-npmrc-for-download.yml@self
parameters:
userNpmrcDirectory: ${{ parameters.userNpmrcDirectory }}

- template: /tools/pipelines/templates/include-telemetry-setup.yml@self
- template: /tools/pipelines/templates/include-install.yml@self
parameters:
pathForTelemetryGeneratorInstall: ${{ parameters.pathForTelemetryGeneratorInstall }}
packageManager: pnpm
buildDirectory: $(Build.SourcesDirectory)
packageManagerInstallCommand: pnpm install
primaryRegistry: $(ado-feeds-ff-download-only)
userNpmrcPath: ${{ parameters.userNpmrcDirectory }}/.npmrc

# Download artifact with test files
- task: DownloadPipelineArtifact@2
Expand All @@ -80,22 +81,6 @@ steps:
# allowPartiallySucceededBuilds: true # No effect as long as we have buildVersionToDownload: specific
# branchName: $(Build.SourceBranch) # No effect as long as we have buildVersionToDownload: specific

- task: Bash@3
displayName: Create test directory
inputs:
targetType: 'inline'
script: |
mkdir ${{ parameters.testWorkspace }}

# Install aria-logger
- task: Bash@3
displayName: 'npm install aria logger'
retryCountOnTaskFailure: 4
inputs:
workingDirectory: ${{ parameters.testWorkspace }}
targetType: 'inline'
script: 'npm install @ff-internal/aria-logger'

- ${{ if eq(parameters.endpointName, 'odsp') }}:
# Log in to Azure to retrieve tenant credentials
- task: AzureCLI@2
Expand All @@ -117,11 +102,10 @@ steps:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
workingDirectory: ${{ parameters.testWorkspace }}
targetType: 'inline'
script: |
set -eu -o pipefail

# Increase the maximum time to wait for a tenant to 1 hour to accommodate multiple test runs at the same time.
npx --package=@ff-internal/[email protected] -- trips-setup --waitTime=3600 --accessToken=$SYSTEM_ACCESSTOKEN
pnpm exec trips-setup --waitTime=3600 --accessToken=$SYSTEM_ACCESSTOKEN
echo "##vso[task.setvariable variable=tenantSetupSuccess;]true"
48 changes: 4 additions & 44 deletions tools/pipelines/templates/include-test-real-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,50 +309,10 @@ stages:
tar --extract --verbose --file $TAR_PATH ./dist/test
tar --extract --verbose --file $TAR_PATH ./src/test

# The test workload we are running frequently depends on devDependencies of the package being installed.
# To make sure these are available, copy them to the root package.json and reinstall.
- task: Bash@3
displayName: Copy devDependencies
inputs:
targetType: 'inline'
script: |
set -eu -o pipefail

testPkgJsonPath=$(Build.SourcesDirectory)/node_modules/${{ parameters.testPackage }}/package.json
pkgJsonPath=$(Build.SourcesDirectory)/package.json
node -e "
const { devDependencies } = require('$testPkgJsonPath');
const pkg = require('$pkgJsonPath');
if (!pkg.devDependencies) {
pkg.devDependencies = {};
}
// Avoid copying some common dev dependencies that should only be required at build time.
// Keeping the dependency tree small helps reduce job time and likelihood of install failures, since
// dependencies added as part of this step won't be reproducible via pnpm-lock.
const avoidCopying = new Set([
'@types/node',
'typescript',
'@microsoft/api-extractor',
'@fluid-tools/build-cli',
'@fluidframework/build-common',
'@fluidframework/build-tools'
]);
for (const [k, v] of Object.entries(devDependencies)) {
if (!pkg.devDependencies[k] && !avoidCopying.has(k)) {
// Note that if you use string interpolation, bash interpreting the dollar sign takes precedence.
console.log('Adding devDependency ' + k + '@' + v);
pkg.devDependencies[k] = v;
}
}
require('fs').writeFileSync('$pkgJsonPath', JSON.stringify(pkg));
"

- task: Bash@3
displayName: 'pnpm install - extra dependencies for test files'
retryCountOnTaskFailure: 10
inputs:
targetType: 'inline'
script: 'pnpm install --no-frozen-lockfile'
- template: /tools/pipelines/templates/include-copy-dev-dependencies.yml@self
parameters:
sourcePackageLocation: $(Build.SourcesDirectory)/node_modules/${{ parameters.testPackage }}
destPackageLocation: $(Build.SourcesDirectory)

- ${{ if eq(parameters.cacheCompatVersionsInstalls, true) }}:
- task: Cache@2
Expand Down
11 changes: 8 additions & 3 deletions tools/pipelines/templates/include-vars-telemetry-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ variables:
- name: pathToTelemetryGenerator
value: $(Agent.TempDirectory)/telemetry-generator
readonly: true

# Path where the handlers for telemetry-generator are located. Convenient because every call to the tool needs to
# provide this as an absolute path.
- name: pathToTelemetryGeneratorHandlers
value: $(pathToTelemetryGenerator)/node_modules/@ff-internal/telemetry-generator/dist/handlers/
value: $(pathToTelemetryGenerator)/node_modules/@ff-internal/telemetry-generator/dist/handlers
readonly: true

# Path where the handlers for telemetry-generator are located when using the ff_pipeline_host repository
# Same semantics as above two variables, but for pipelines that use the new ff_pipeline_host repository setup
# for shared internal dependencies.
- name: pathToTelemetryGeneratorNew
value: $(Build.SourcesDirectory)/node_modules/@ff-internal/telemetry-generator
readonly: true

- name: pathToTelemetryGeneratorHandlersNew
value: $(Build.SourcesDirectory)/node_modules/@ff-internal/telemetry-generator/dist/handlers/
value: $(Build.SourcesDirectory)/node_modules/@ff-internal/telemetry-generator/dist/handlers
readonly: true
Loading
Loading