Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable log #7184

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
Expand All @@ -12,6 +13,41 @@ import { Reporter } from "@itwin/perf-tools";
import DisplayPerfRpcInterface from "../common/DisplayPerfRpcInterface";
import { addColumnsToCsvFile, addDataToCsvFile, addEndOfTestToCsvFile, createFilePath, createNewCsvFile } from "./CsvWriter";
import { DptaEnvConfig, getConfig } from "../common/DisplayPerfEnvConfig";
import * as child_process from "child_process";

function killProcess(processId: number) {
try {
console.log(`Killing process ${processId}`);
if (process.platform === "win32") {
try {
child_process.execSync(`taskkill /pid ${processId} /T /F`);
} catch (error) {
console.error(error);
console.error(`Killing ${processId} using taskkill failed`, error);
// taskkill can fail to kill the process e.g. due to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
process.kill(processId);
}
} else {
try {
// on linux the process group can be killed with the group id prefixed with
// a minus sign. The process group id is the group leader's pid.
process.kill(-processId, "SIGKILL");
} catch (error) {
console.error(error);
console.error(`Killing ${processId} using process.kill failed.`);
// Killing the process group can fail due e.g. to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
process.kill(processId, "SIGKILL");
}
}
} catch (error) {
console.error(`DPTA was unable to kill the process.`);
console.error(error);
}
}

/** The backend implementation of DisplayPerfRpcImpl. */
export default class DisplayPerfRpcImpl extends DisplayPerfRpcInterface {
Expand Down Expand Up @@ -166,6 +202,9 @@ export default class DisplayPerfRpcImpl extends DisplayPerfRpcInterface {
}

public override async terminate() {

console.log("backlog: terminating");

await IModelHost.shutdown();

// Electron only
Expand All @@ -181,6 +220,8 @@ export default class DisplayPerfRpcImpl extends DisplayPerfRpcInterface {

if (DisplayPerfRpcInterface.chrome)
DisplayPerfRpcInterface.chrome.kill();

console.log("backlog: terminated");
}

private createFullFilePath(filePath: string | undefined, fileName: string | undefined): string | undefined {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
Expand All @@ -17,6 +18,7 @@ import { IModelsClient } from "@itwin/imodels-client-management";
import DisplayPerfRpcInterface from "../common/DisplayPerfRpcInterface";
import { TestRunner, TestSetsProps } from "./TestRunner";
import { DptaEnvConfig } from "../common/DisplayPerfEnvConfig";
import { child_process } from "child_process";

export const envConfiguration: DptaEnvConfig = {};
let runner: TestRunner;
Expand Down Expand Up @@ -89,7 +91,7 @@ export class DisplayPerfTestApp {

const frontendTilesNopFallback = (runner && runner.curConfig && runner.curConfig.frontendTilesNopFallback) ? runner.curConfig.frontendTilesNopFallback : false;

if(frontendTilesNopFallback){
if (frontendTilesNopFallback) {
await DisplayPerfRpcInterface.getClient().consoleLog("Nop fallback enabled for frontend tiles.");
}

Expand Down Expand Up @@ -168,13 +170,18 @@ async function main() {
} catch (err: any) {
await DisplayPerfTestApp.logException(err);
} finally {
console.log("Frontend: terminating");
await DisplayPerfRpcInterface.getClient().terminate();
}

return IModelApp.shutdown();
console.log("Frontend: shutting down");
await IModelApp.shutdown();
console.log("Frontend: shut down");
}

window.onload = async () => {

console.log("Frontend: initializing...");

// Choose RpcConfiguration based on whether we are in electron or browser
RpcConfiguration.developmentMode = true;
RpcConfiguration.disableRoutingValidation = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { RealityDataAccessClient, RealityDataClientOptions } from "@itwin/reality-data-client";
import {
assert, Dictionary, Id64, Id64Array, Id64String, ProcessDetector, SortedArray, StopWatch,
assert, Dictionary, Id64, Id64Array, Id64String, Logger, LoggingMetaData, LogLevel, ProcessDetector, SortedArray, StopWatch,
} from "@itwin/core-bentley";
import {
BackgroundMapType, BaseMapLayerSettings, DisplayStyleProps, FeatureAppearance, Hilite, RenderMode, ViewStateProps,
Expand Down Expand Up @@ -209,6 +209,14 @@ export class TestRunner {
await this.logToConsole(msg);
await this.logToFile(msg, { noAppend: true });

// eslint-disable-next-line no-console
console.log("Running tests...");
// const logConsole = (level: string) => async (category: string, message: string, metaData: LoggingMetaData) =>
// this.logToConsole(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`);

// Logger.initialize(logConsole("Error"), logConsole("Warning"), logConsole("Info"), logConsole("Trace"));
// Logger.setLevelDefault(LogLevel.Info);

let needRestart = this.curConfig.requiresRestart(new TestConfig({})); // If current config differs from default, restart
const renderOptions: RenderSystem.Options = this.curConfig.renderOptions ?? {};
if (!this.curConfig.useDisjointTimer) {
Expand Down
Loading