Skip to content

Commit

Permalink
test: migration remote debug use cli (#11288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayachensiyuan authored Apr 7, 2024
1 parent a0ea763 commit d2300f3
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ describe("Migration Tests", function () {
CliHelper.setV3Enable();

// v3 provision
await reRunProvision();
await reRunDeploy(Timeout.botDeploy);
await mirgationDebugTestContext.provisionProject(
mirgationDebugTestContext.appName,
mirgationDebugTestContext.projectPath
);
await mirgationDebugTestContext.deployProject(
mirgationDebugTestContext.projectPath,
Timeout.botDeploy
);

// UI verify
const teamsAppId = await mirgationDebugTestContext.getTeamsAppId("dev");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ describe("Migration Tests", function () {
CliHelper.setV3Enable();

// v3 provision
await runProvision(mirgationDebugTestContext.appName);
await runDeploy(Timeout.botDeploy);
await mirgationDebugTestContext.provisionProject(
mirgationDebugTestContext.appName,
mirgationDebugTestContext.projectPath
);
await mirgationDebugTestContext.deployProject(
mirgationDebugTestContext.projectPath,
Timeout.botDeploy
);

// UI verify
const teamsAppId = await mirgationDebugTestContext.getTeamsAppId("dev");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ describe("Migration Tests", function () {
CliHelper.setV3Enable();

// v3 provision
await reRunProvision();
await reRunDeploy(Timeout.botDeploy);
await mirgationDebugTestContext.provisionProject(
mirgationDebugTestContext.appName,
mirgationDebugTestContext.projectPath
);
await mirgationDebugTestContext.deployProject(
mirgationDebugTestContext.projectPath,
Timeout.botDeploy
);

// UI verify
const teamsAppId = await mirgationDebugTestContext.getTeamsAppId("dev");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ describe("Migration Tests", function () {
CliHelper.setV3Enable();

// v3 provision
await runProvision(mirgationDebugTestContext.appName);
await runDeploy(Timeout.botDeploy);
await mirgationDebugTestContext.provisionProject(
mirgationDebugTestContext.appName,
mirgationDebugTestContext.projectPath
);
await mirgationDebugTestContext.deployProject(
mirgationDebugTestContext.projectPath,
Timeout.botDeploy
);

// UI verify
const teamsAppId = await mirgationDebugTestContext.getTeamsAppId("dev");
Expand Down
87 changes: 87 additions & 0 deletions packages/tests/src/ui-test/migration/migrationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Trigger,
Framework,
TestFilePath,
Timeout,
} from "../../utils/constants";
import { TestContext } from "../testContext";
import { CliHelper } from "../cliHelper";
Expand All @@ -18,9 +19,11 @@ import {
cleanAppStudio,
cleanTeamsApp,
GraphApiCleanHelper,
createResourceGroup,
} from "../../utils/cleanHelper";
import { isV3Enabled } from "@microsoft/teamsfx-core";
import { AzSqlHelper } from "../../utils/azureCliHelper";
import { runProvision, runDeploy } from "../remotedebug/remotedebugContext";

export class MigrationTestContext extends TestContext {
public testName: Capability;
Expand Down Expand Up @@ -252,4 +255,88 @@ export class MigrationTestContext extends TestContext {
await cleanTeamsApp(this.appName);
await cleanAppStudio(this.appName);
}

public async provisionProject(
appName: string,
projectPath = "",
createRg = true,
tool: "ttk" | "cli" = "cli",
option = "",
env: "dev" | "local" = "dev",
processEnv?: NodeJS.ProcessEnv
) {
if (tool === "cli") {
await this.runCliProvision(
projectPath,
appName,
createRg,
option,
env,
processEnv
);
} else {
await runProvision(appName);
}
}

public async deployProject(
projectPath: string,
waitTime: number = Timeout.tabDeploy,
tool: "ttk" | "cli" = "cli",
option = "",
env: "dev" | "local" = "dev",
processEnv?: NodeJS.ProcessEnv,
retries?: number,
newCommand?: string
) {
if (tool === "cli") {
await this.runCliDeploy(
projectPath,
option,
env,
processEnv,
retries,
newCommand
);
} else {
await runDeploy(waitTime);
}
}

public async runCliProvision(
projectPath: string,
appName: string,
createRg = true,
option = "",
env: "dev" | "local" = "dev",
processEnv?: NodeJS.ProcessEnv
) {
if (createRg) {
await createResourceGroup(appName, env, "westus");
}
const resourceGroupName = `${appName}-${env}-rg`;
await CliHelper.showVersion(projectPath, processEnv);
await CliHelper.provisionProject2(projectPath, option, env, {
...process.env,
AZURE_RESOURCE_GROUP_NAME: resourceGroupName,
});
}

public async runCliDeploy(
projectPath: string,
option = "",
env: "dev" | "local" = "dev",
processEnv?: NodeJS.ProcessEnv,
retries?: number,
newCommand?: string
) {
await CliHelper.deployAll(
projectPath,
option,
env,
processEnv,
retries,
newCommand
);
}
}

0 comments on commit d2300f3

Please sign in to comment.