test fixes

test fixes
- fix timeout in redis (by @ajayyy)
- allow "errors" in tempVIP test
- remove duplicate warning in postSkipSegments
- remove duplicate VIP in tempVIP
- run tests against different user once tempVIP removed
- fix typo in getHashCache fetching

syntax and wording
- use standard syntax in redisTest
- fix spacing in getLockReason
- typo in npm script name

test cases
- add getHashCache test case
- add more tests to redisTest

configuration
- update config to use redis timeout
- update docker-compose to use newest pinned version

Co-Authored-By: Ajay Ramachandran <dev@ajay.app>
This commit is contained in:
Michael C
2022-09-02 01:22:04 -04:00
parent ab6fcb8943
commit d1d7675a8c
12 changed files with 88 additions and 30 deletions

View File

@@ -5,7 +5,7 @@ import { config } from "../config";
import util from "util";
import fs from "fs";
import path from "path";
import { ChildProcess, exec, ExecOptions, spawn } from "child_process";
import { exec, ExecOptions } from "child_process";
const unlink = util.promisify(fs.unlink);
const ONE_MINUTE = 1000 * 60;
@@ -44,7 +44,7 @@ const credentials: ExecOptions = {
PGPASSWORD: String(config.postgres.password),
PGDATABASE: "sponsorTimes",
}
}
};
interface TableDumpList {
fileName: string;
@@ -232,7 +232,7 @@ async function queueDump(): Promise<void> {
resolve(error ? stderr : stdout);
});
})
});
dumpFiles.push({
fileName,

View File

@@ -26,11 +26,13 @@ async function getFromRedis<T extends string>(key: HashedValue): Promise<T & Has
Logger.debug(`Got data from redis: ${reply}`);
return reply as T & HashedValue;
}
} catch (e) {} // eslint-disable-line no-empty
} catch (err) {
Logger.error(err as string);
}
// Otherwise, calculate it
const data = getHash(key, cachedHashTimes);
redis.set(key, data).catch((err) => Logger.error(err));
redis.set(redisKey, data).catch((err) => Logger.error(err));
return data as T & HashedValue;
}

View File

@@ -33,7 +33,7 @@ if (config.redis?.enabled) {
const get = client.get.bind(client);
exportClient.get = (key) => new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(), config.redis.getTimeout);
const timeout = config.redis.getTimeout ? setTimeout(() => reject(), config.redis.getTimeout) : null;
get(key).then((reply) => {
clearTimeout(timeout);
resolve(reply);
@@ -48,7 +48,10 @@ if (config.redis?.enabled) {
.catch((err) => reject(err))
);
client.on("error", function(error) {
Logger.error(error);
Logger.error(`Redis Error: ${error}`);
});
client.on("reconnect", () => {
Logger.info("Redis: trying to reconnect");
});
}