mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-09-29 20:56:23 +00:00
Tidy logging in integration tests
This commit is contained in:
parent
400af48e6e
commit
776c1fe063
@ -293,6 +293,7 @@ export class Mjolnir {
|
|||||||
* Stop Mjolnir from syncing and processing commands.
|
* Stop Mjolnir from syncing and processing commands.
|
||||||
*/
|
*/
|
||||||
public stop() {
|
public stop() {
|
||||||
|
LogService.info("Mjolnir", "Stopping Mjolnir...");
|
||||||
this.client.stop();
|
this.client.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { HmacSHA1 } from "crypto-js";
|
import { HmacSHA1 } from "crypto-js";
|
||||||
import { MatrixClient, MemoryStorageProvider, PantalaimonClient } from "matrix-bot-sdk";
|
import { LogService, MatrixClient, MemoryStorageProvider, PantalaimonClient } from "matrix-bot-sdk";
|
||||||
import config from "../../src/config";
|
import config from "../../src/config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,8 +40,7 @@ export async function registerNewTestUser(isAdmin: boolean) {
|
|||||||
username = `mjolnir-test-user-${Math.floor(Math.random() * 100000)}`
|
username = `mjolnir-test-user-${Math.floor(Math.random() * 100000)}`
|
||||||
await registerUser(username, username, username, isAdmin).then(_ => isUserValid = true).catch(e => {
|
await registerUser(username, username, username, isAdmin).then(_ => isUserValid = true).catch(e => {
|
||||||
if (e.isAxiosError && e?.response?.data?.errcode === 'M_USER_IN_USE') {
|
if (e.isAxiosError && e?.response?.data?.errcode === 'M_USER_IN_USE') {
|
||||||
// FIXME: Replace with the real logging service.
|
LogService.debug("test/clientHelper", `${username} already registered, trying another`);
|
||||||
console.log(`${username} already registered, trying another`);
|
|
||||||
false // continue and try again
|
false // continue and try again
|
||||||
} else {
|
} else {
|
||||||
console.error(`failed to register user ${e}`);
|
console.error(`failed to register user ${e}`);
|
||||||
|
@ -16,7 +16,6 @@ export const mochaHooks = {
|
|||||||
],
|
],
|
||||||
afterEach: [
|
afterEach: [
|
||||||
async function() {
|
async function() {
|
||||||
console.log("stopping mjolnir");
|
|
||||||
await this.mjolnir.stop();
|
await this.mjolnir.stop();
|
||||||
// Mjolnir resolves config.managementRoom and overwrites it, so we undo this here
|
// Mjolnir resolves config.managementRoom and overwrites it, so we undo this here
|
||||||
// after stopping Mjolnir for the next time we setup a Mjolnir and a management room.
|
// after stopping Mjolnir for the next time we setup a Mjolnir and a management room.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { doesNotMatch } from "assert";
|
|
||||||
import { assert } from "console";
|
|
||||||
import config from "../../src/config";
|
import config from "../../src/config";
|
||||||
import { newTestUser, noticeListener } from "./clientHelper"
|
import { newTestUser, noticeListener } from "./clientHelper"
|
||||||
|
|
||||||
@ -17,7 +15,6 @@ describe("help command", () => {
|
|||||||
// listener for getting the event reply
|
// listener for getting the event reply
|
||||||
let reply = new Promise((resolve, reject) => {
|
let reply = new Promise((resolve, reject) => {
|
||||||
client.on('room.message', noticeListener(config.managementRoom, (event) => {
|
client.on('room.message', noticeListener(config.managementRoom, (event) => {
|
||||||
console.log(event.event_id)
|
|
||||||
if (event.content.body.includes("Print status information")) {
|
if (event.content.body.includes("Print status information")) {
|
||||||
resolve(event);
|
resolve(event);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ limitations under the License.
|
|||||||
import {
|
import {
|
||||||
MatrixClient,
|
MatrixClient,
|
||||||
PantalaimonClient,
|
PantalaimonClient,
|
||||||
MemoryStorageProvider
|
MemoryStorageProvider,
|
||||||
|
LogService,
|
||||||
|
LogLevel,
|
||||||
|
RichConsoleLogger
|
||||||
} from "matrix-bot-sdk";
|
} from "matrix-bot-sdk";
|
||||||
import { Mjolnir} from '../../src/Mjolnir';
|
import { Mjolnir} from '../../src/Mjolnir';
|
||||||
import config from "../../src/config";
|
import config from "../../src/config";
|
||||||
@ -57,7 +60,9 @@ async function configureMjolnir() {
|
|||||||
|
|
||||||
export async function makeMjolnir() {
|
export async function makeMjolnir() {
|
||||||
await configureMjolnir();
|
await configureMjolnir();
|
||||||
console.info('starting mjolnir');
|
LogService.setLogger(new RichConsoleLogger());
|
||||||
|
LogService.setLevel(LogLevel.fromString(config.logLevel, LogLevel.DEBUG));
|
||||||
|
LogService.info("test/mjolnirSetupUtils", "Starting bot...");
|
||||||
const pantalaimon = new PantalaimonClient(config.homeserverUrl, new MemoryStorageProvider());
|
const pantalaimon = new PantalaimonClient(config.homeserverUrl, new MemoryStorageProvider());
|
||||||
const client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
|
const client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
|
||||||
await ensureAliasedRoomExists(client, config.managementRoom);
|
await ensureAliasedRoomExists(client, config.managementRoom);
|
||||||
|
Loading…
Reference in New Issue
Block a user