Skip to content

Commit 05bee27

Browse files
authored
Fix and re-enable long running tests (#786)
1 parent cd1e562 commit 05bee27

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

extension.bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// At runtime the tests live in dist/tests and will therefore pick up the main webpack bundle at dist/extension.bundle.js.
1717
export * from '@microsoft/vscode-azext-utils';
1818
// Export activate/deactivate for main.js
19+
export * from './src/commands/createManagedEnvironment/createManagedEnvironment';
1920
export * from './src/commands/deployWorkspaceProject/deployWorkspaceProject';
2021
export * from './src/commands/deployWorkspaceProject/getDeployWorkspaceProjectResults';
2122
export * from './src/commands/deployWorkspaceProject/internal/DeployWorkspaceProjectInternalContext';

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@
773773
"devDependencies": {
774774
"@azure/ms-rest-azure-env": "^2.0.0",
775775
"@microsoft/eslint-config-azuretools": "^0.2.2",
776-
"@microsoft/vscode-azext-dev": "^2.0.4",
776+
"@microsoft/vscode-azext-dev": "^2.0.5",
777777
"@types/deep-eql": "^4.0.0",
778778
"@types/fs-extra": "^8.1.1",
779779
"@types/gulp": "^4.0.6",
@@ -810,7 +810,7 @@
810810
"@azure/storage-blob": "^12.4.1",
811811
"@microsoft/vscode-azext-azureutils": "^3.1.1",
812812
"@microsoft/vscode-azext-github": "^1.0.0",
813-
"@microsoft/vscode-azext-utils": "^2.5.10",
813+
"@microsoft/vscode-azext-utils": "^2.5.11",
814814
"@microsoft/vscode-azureresources-api": "^2.0.2",
815815
"buffer": "^6.0.3",
816816
"dayjs": "^1.11.3",

src/commands/createManagedEnvironment/createManagedEnvironment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { type ManagedEnvironment } from "@azure/arm-appcontainers";
67
import { LocationListStep, ResourceGroupCreateStep } from "@microsoft/vscode-azext-azureutils";
78
import { AzureWizard, createSubscriptionContext, nonNullProp, subscriptionExperience, type AzureWizardExecuteStep, type AzureWizardPromptStep, type IActionContext } from "@microsoft/vscode-azext-utils";
89
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
@@ -16,7 +17,7 @@ import { type ManagedEnvironmentCreateContext } from "./ManagedEnvironmentCreate
1617
import { ManagedEnvironmentCreateStep } from "./ManagedEnvironmentCreateStep";
1718
import { ManagedEnvironmentNameStep } from "./ManagedEnvironmentNameStep";
1819

19-
export async function createManagedEnvironment(context: IActionContext, node?: { subscription: AzureSubscription }): Promise<void> {
20+
export async function createManagedEnvironment(context: IActionContext, node?: { subscription: AzureSubscription }): Promise<ManagedEnvironment> {
2021
const subscription = node?.subscription ?? await subscriptionExperience(context, ext.rgApiV2.resources.azureResourceTreeDataProvider);
2122

2223
const wizardContext: ManagedEnvironmentCreateContext = {
@@ -54,4 +55,5 @@ export async function createManagedEnvironment(context: IActionContext, node?: {
5455
await wizard.execute();
5556

5657
ext.branchDataProvider.refresh();
58+
return nonNullProp(wizardContext, 'managedEnvironment');
5759
}

test/global.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import * as assert from 'assert';
99
import * as vscode from 'vscode';
1010
import { ext, registerOnActionStartHandler, registerUIExtensionVariables } from '../extension.bundle';
1111

12-
// const longRunningLocalTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_EnableLongRunningTestsLocal || '');
13-
// const longRunningRemoteTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_UseAzureFederatedCredentials || '');
12+
const longRunningLocalTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_EnableLongRunningTestsLocal || '');
13+
const longRunningRemoteTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_UseAzureFederatedCredentials || '');
1414

15-
// export const longRunningTestsEnabled: boolean = longRunningLocalTestsEnabled || longRunningRemoteTestsEnabled;
16-
17-
export const longRunningTestsEnabled: boolean = false;
15+
export const longRunningTestsEnabled: boolean = longRunningLocalTestsEnabled || longRunningRemoteTestsEnabled;
1816

1917
// Runs before all tests
2018
suiteSetup(async function (this: Mocha.Context): Promise<void> {

test/nightly/deployWorkspaceProject/deployWorkspaceProject.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { type ManagedEnvironment } from '@azure/arm-appcontainers';
67
import { runWithTestActionContext } from '@microsoft/vscode-azext-dev';
7-
import { parseError, type IParsedError } from "@microsoft/vscode-azext-utils";
8+
import { nonNullProp, parseError, randomUtils, type IParsedError } from "@microsoft/vscode-azext-utils";
89
import * as assert from 'assert';
910
import * as path from 'path';
1011
import { workspace, type Uri, type WorkspaceFolder } from 'vscode';
11-
import { AzExtFsExtra, deployWorkspaceProject, dwpSettingUtilsV2, settingUtils, type DeploymentConfigurationSettings, type DeployWorkspaceProjectResults } from '../../../extension.bundle';
12+
import { AzExtFsExtra, createManagedEnvironment, deployWorkspaceProject, dwpSettingUtilsV2, settingUtils, type DeploymentConfigurationSettings, type DeployWorkspaceProjectResults } from '../../../extension.bundle';
1213
import { longRunningTestsEnabled } from '../../global.test';
1314
import { assertStringPropsMatch, getWorkspaceFolderUri } from '../../testUtils';
1415
import { resourceGroupsToDelete } from '../global.nightly.test';
@@ -17,10 +18,17 @@ import { dwpTestScenarios } from './dwpTestScenarios';
1718
suite('deployWorkspaceProject', function (this: Mocha.Suite) {
1819
this.timeout(15 * 60 * 1000);
1920

20-
suiteSetup(function (this: Mocha.Context) {
21+
suiteSetup(async function (this: Mocha.Context) {
2122
if (!longRunningTestsEnabled) {
2223
this.skip();
2324
}
25+
26+
// Create a managed environment first so that we can guarantee one is always built before workspace deployment tests start.
27+
// This is crucial for test consistency because the managed environment prompt will skip if no managed environment
28+
// resources are available yet. Creating at least one environment first ensures consistent reproduceability.
29+
const managedEnvironment: ManagedEnvironment | undefined = await setupManagedEnvironment();
30+
assert.ok(managedEnvironment, 'Failed to create managed environment - skipping "deployWorkspaceProject" tests.');
31+
resourceGroupsToDelete.add(nonNullProp(managedEnvironment, 'name'));
2432
});
2533

2634
for (const scenario of dwpTestScenarios) {
@@ -83,6 +91,17 @@ suite('deployWorkspaceProject', function (this: Mocha.Suite) {
8391
}
8492
});
8593

94+
async function setupManagedEnvironment(): Promise<ManagedEnvironment | undefined> {
95+
let managedEnvironment: ManagedEnvironment | undefined;
96+
await runWithTestActionContext('createManagedEnvironment', async context => {
97+
const resourceName: string = 'dwp' + randomUtils.getRandomHexString(6);
98+
await context.ui.runWithInputs([resourceName, 'East US'], async () => {
99+
managedEnvironment = await createManagedEnvironment(context);
100+
});
101+
});
102+
return managedEnvironment;
103+
}
104+
86105
function getMethodCleanWorkspaceFolderSettings(rootFolder: WorkspaceFolder) {
87106
return async function cleanWorkspaceFolderSettings(): Promise<void> {
88107
const settingsPath: string = settingUtils.getDefaultRootWorkspaceSettingsPath(rootFolder);

test/nightly/deployWorkspaceProject/testCases/albumApiJavaScriptTestCases.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export function generateAlbumApiJavaScriptTestCases(): DeployWorkspaceProjectTes
2727
sharedResourceName.slice(0, -1), // Isolate by using a different resource group name since we expect this case to fail
2828
appResourceName,
2929
`.${path.sep}src`,
30+
'Docker Login Credentials',
31+
'Enable',
3032
'East US',
3133
'Save'
3234
],
@@ -45,6 +47,8 @@ export function generateAlbumApiJavaScriptTestCases(): DeployWorkspaceProjectTes
4547
sharedResourceName,
4648
appResourceName,
4749
`.${path.sep}src`,
50+
'Docker Login Credentials',
51+
'Enable',
4852
'East US',
4953
'Save'
5054
],

test/nightly/deployWorkspaceProject/testCases/monoRepoBasicTestCases.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export function generateMonoRepoBasicTestCases(): DeployWorkspaceProjectTestCase
2626
sharedResourceName,
2727
'app1',
2828
`.${path.sep}app1`,
29+
'Docker Login Credentials',
30+
'Enable',
2931
path.join('app1', '.env.example'),
3032
'East US',
3133
'Save'
@@ -49,6 +51,7 @@ export function generateMonoRepoBasicTestCases(): DeployWorkspaceProjectTestCase
4951
'Continue',
5052
'app2',
5153
`.${path.sep}app2`,
54+
'Docker Login Credentials',
5255
path.join('app2', '.env.example'),
5356
'Save'
5457
],
@@ -71,6 +74,7 @@ export function generateMonoRepoBasicTestCases(): DeployWorkspaceProjectTestCase
7174
'Continue',
7275
'app3',
7376
`.${path.sep}app3`,
77+
'Docker Login Credentials',
7478
path.join('app3', '.env.example'),
7579
'Save'
7680
],

test/test.code-workspace

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"folders": [
3-
{
4-
"name": "albumapi-go",
5-
"path": "./testProjects/containerapps-albumapi-go"
6-
},
73
{
84
"name": "albumapi-js",
95
"path": "./testProjects/containerapps-albumapi-javascript"

0 commit comments

Comments
 (0)