Fixing Random Test Failure (#309)

* Test 1: Async Wrapping

* Revert "Test 1: Async Wrapping"

This reverts commit 8f0e0d283686d367e18275684cc7858af0538515.

* Pin github actions node version to the same as ours

* Revert "Pin github actions node version to the same as ours"

This reverts commit 3758ee05ef5647f608ef3fd1c85b88eb97e3f077.

* Move lint step to after running tests

* add a NO_CONSOLE config option

* temporarily set log level to debug

* Enable more mongodb logging in testing

* Experimentally bundle before script into SPT.

* run without any before

* Revert "Experimentally bundle before script into SPT."

* Revert "Enable more mongodb logging in testing"

This reverts commit c11f918c850dc53cb49b262cb0b51141ac132aab.

* Fix missing import

* Re add the mongodb logging

* Set LOG_LEVEL back to reasonable levels

* Increase timeouts for mongo and redis connections

* Change how codecov works

* Use ServerSelectionTimeoutMS instead of connect

* pls?

* Bump TAP Timeout to 4 minutes, which we'll probably never hit.
This commit is contained in:
zkldi
2021-09-01 06:26:37 +01:00
committed by GitHub
parent 054eb4659b
commit b79804d273
7 changed files with 33 additions and 40 deletions
+4 -10
View File
@@ -7,21 +7,15 @@ coverage:
round: down
range: "50...100"
status:
patch:
default:
informational: true
project:
default:
target: 80
threshold: 2
base: auto
flags:
- unit
paths:
- "src"
# advanced settings
branches:
- master
if_ci_failed: error #success, failure, error, ignore
informational: false
only_pulls: false
informational: true
parsers:
gcov:
+3 -3
View File
@@ -38,12 +38,12 @@ jobs:
- name: Move Config File
run: mv ./.github/test.conf.json5 ./test.conf.json5
- name: Lint Code
run: pnpm lint
- name: Run Tests
run: pnpm test
- name: Lint Code
run: pnpm lint
- name: Upload Coverage
if: always()
run: |
+1 -1
View File
@@ -1,6 +1,6 @@
files: "src/test-utils/single-process-tap.ts"
test-env: [NODE_ENV=test, TCHIS_CONF_LOCATION=test.conf.json5]
timeout: 120 # might need to be increased
timeout: 240 # Was increased for slow github runners. Might be insufferable for real world use.
ts: true
before: "./src/test-utils/hack-setup.js"
check-coverage: true
+9 -10
View File
@@ -35,6 +35,7 @@ import CreateLogCtx from "lib/logger/logger";
import { OrphanScoreDocument } from "lib/score-import/import-types/common/types";
import { GetMilisecondsSince } from "utils/misc";
import { ServerConfig } from "lib/setup/config";
import { ONE_MINUTE } from "lib/constants/time";
const logger = CreateLogCtx(__filename);
@@ -45,21 +46,19 @@ if (process.env.NODE_ENV === "test") {
dbName = `testingdb`;
}
let dbtime: bigint;
/* istanbul ignore next */
if (process.env.NODE_ENV !== "test") {
logger.info(`Connecting to database ${ServerConfig.MONGO_CONNECTION_URL}/${dbName}...`);
dbtime = process.hrtime.bigint();
}
logger.info(`Connecting to database ${ServerConfig.MONGO_CONNECTION_URL}/${dbName}...`);
const dbtime = process.hrtime.bigint();
export const monkDB = monk(`${ServerConfig.MONGO_CONNECTION_URL}/${dbName}`);
// By default the connectTimeoutMS is 30 seconds. This has been upped to 2 minutes, due to poor performance
// inside githubs test runners.
export const monkDB = monk(`${ServerConfig.MONGO_CONNECTION_URL}/${dbName}`, {
serverSelectionTimeoutMS: ONE_MINUTE * 2,
});
/* istanbul ignore next */
monkDB
.then(() => {
if (process.env.NODE_ENV !== "test") {
logger.info(`Database connection successful: took ${GetMilisecondsSince(dbtime!)}ms`);
}
logger.info(`Database connection successful: took ${GetMilisecondsSince(dbtime)}ms`);
})
.catch((err) => {
logger.crit(err);
+1 -1
View File
@@ -15,7 +15,7 @@ function EmitCritical() {
}
}
const ref = setTimeout(EmitCritical, 10000);
const ref = setTimeout(EmitCritical, 30000);
RedisClient.on("connect", () => {
logger.verbose(`Connected to Redis.`);
+13 -15
View File
@@ -98,26 +98,24 @@ const consoleFormatRoute = format.combine(
})
);
let tports: (
const tports: (
| winston.transports.ConsoleTransportInstance
| winston.transports.FileTransportInstance
)[] = [];
)[] = [
new transports.File({
filename: "logs/tachi-error.log",
level: "error",
format: defaultFormatRoute,
}),
new transports.File({ filename: "logs/tachi.log", format: defaultFormatRoute }),
];
/* istanbul ignore next */
if (IN_TESTING) {
tports = [new transports.File({ filename: "logs/tachi-test.log", format: defaultFormatRoute })];
} else {
tports = [
new transports.File({
filename: "logs/tachi-error.log",
level: "error",
format: defaultFormatRoute,
}),
new transports.File({ filename: "logs/tachi.log", format: defaultFormatRoute }),
if (!ServerConfig.NO_CONSOLE) {
tports.push(
new transports.Console({
format: consoleFormatRoute,
}),
];
})
);
}
export const rootLogger = winston.createLogger({
+2
View File
@@ -66,6 +66,7 @@ export interface TachiConfig {
SERVER_TYPE_INFO: StaticConfig.ServerConfig;
RATE_LIMIT: integer;
OPTIONS_ALWAYS_SUCCEEDS?: boolean;
NO_CONSOLE?: boolean;
}
const isValidOauth2 = p.optional({
@@ -95,6 +96,7 @@ const err = p(config, {
TYPE: p.isIn("ktchi", "btchi", "omni"),
RATE_LIMIT: p.optional(p.isPositiveInteger),
OPTIONS_ALWAYS_SUCCEEDS: "*boolean",
NO_CONSOLE: "*boolean",
});
if (err) {