taler-harness: clean up shared test env on start
This commit is contained in:
parent
55bdc161b5
commit
9402aeef5b
@ -215,10 +215,14 @@ export async function createSimpleTestkudosEnvironment(
|
||||
};
|
||||
}
|
||||
|
||||
export function getSharedTestDir(): string {
|
||||
return `/tmp/taler-harness@${process.env.USER}`;
|
||||
}
|
||||
|
||||
export async function useSharedTestkudosEnvironment(t: GlobalTestState) {
|
||||
const coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS"));
|
||||
|
||||
const sharedDir = `/tmp/taler-harness@${process.env.USER}`;
|
||||
const sharedDir = getSharedTestDir();
|
||||
|
||||
fs.mkdirSync(sharedDir, { recursive: true });
|
||||
|
||||
@ -230,10 +234,9 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) {
|
||||
|
||||
logger.info(`previous setup done: ${prevSetupDone}`);
|
||||
|
||||
|
||||
// Wallet has longer startup-time and no dependencies,
|
||||
// so we start it rather early.
|
||||
const walletStartProm = createWalletDaemonWithClient(t, { name: "wallet" })
|
||||
const walletStartProm = createWalletDaemonWithClient(t, { name: "wallet" });
|
||||
|
||||
if (fs.existsSync(sharedDir + "/bank.conf")) {
|
||||
logger.info("reusing existing bank");
|
||||
@ -361,7 +364,7 @@ export async function useSharedTestkudosEnvironment(t: GlobalTestState) {
|
||||
}
|
||||
};
|
||||
|
||||
await bankStart()
|
||||
await bankStart();
|
||||
|
||||
const res = await Promise.all([
|
||||
exchangeStart(),
|
||||
|
@ -27,10 +27,12 @@ import * as path from "path";
|
||||
import url from "url";
|
||||
import {
|
||||
GlobalTestState,
|
||||
runCommand,
|
||||
runTestWithState,
|
||||
shouldLingerInTest,
|
||||
TestRunResult,
|
||||
} from "../harness/harness.js";
|
||||
import { spawnSync } from "child_process";
|
||||
import { runAgeRestrictionsMerchantTest } from "./test-age-restrictions-merchant.js";
|
||||
import { runBankApiTest } from "./test-bank-api.js";
|
||||
import { runClaimLoopTest } from "./test-claim-loop.js";
|
||||
@ -111,6 +113,7 @@ import { runPaymentShareTest } from "./test-payment-share.js";
|
||||
import { runSimplePaymentTest } from "./test-simple-payment.js";
|
||||
import { runTermOfServiceFormatTest } from "./test-tos-format.js";
|
||||
import { runExchangePurseTest } from "./test-exchange-purse.js";
|
||||
import { getSharedTestDir } from "../harness/helpers.js";
|
||||
|
||||
/**
|
||||
* Test runner.
|
||||
@ -264,7 +267,37 @@ interface RunTestChildInstruction {
|
||||
testRootDir: string;
|
||||
}
|
||||
|
||||
function purgeSharedTestEnvironment() {
|
||||
const rmRes = spawnSync("rm", ["-rf", `${getSharedTestDir()}`]);
|
||||
if (rmRes.status != 0) {
|
||||
logger.warn("can't delete shared test directory");
|
||||
}
|
||||
const psqlRes = spawnSync("psql", ["-Aqtl"], {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (psqlRes.status != 0) {
|
||||
logger.warn("could not list available postgres databases");
|
||||
return;
|
||||
}
|
||||
if (psqlRes.output[1]!!.indexOf("taler-integrationtest-shared") >= 0) {
|
||||
const dropRes = spawnSync("dropdb", ["taler-integrationtest-shared"], {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (dropRes.status != 0) {
|
||||
logger.warn("could not drop taler-integrationtest-shared database");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function runTests(spec: TestRunSpec) {
|
||||
if (!process.env.TALER_HARNESS_KEEP) {
|
||||
logger.info("purging shared test environment");
|
||||
purgeSharedTestEnvironment();
|
||||
} else {
|
||||
logger.info("keeping shared test environment");
|
||||
}
|
||||
|
||||
const testRootDir = fs.mkdtempSync(
|
||||
path.join(os.tmpdir(), "taler-integrationtests-"),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user