reduce verbosity a bit, add convenience symlink
This commit is contained in:
parent
1fa3cad2e7
commit
100f4fc5fb
@ -63,13 +63,17 @@ interface WaitResult {
|
|||||||
/**
|
/**
|
||||||
* Run a shell command, return stdout.
|
* Run a shell command, return stdout.
|
||||||
*/
|
*/
|
||||||
export async function sh(command: string): Promise<string> {
|
export async function sh(
|
||||||
|
t: GlobalTestState,
|
||||||
|
logName: string,
|
||||||
|
command: string,
|
||||||
|
): Promise<string> {
|
||||||
console.log("runing command");
|
console.log("runing command");
|
||||||
console.log(command);
|
console.log(command);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const stdoutChunks: Buffer[] = [];
|
const stdoutChunks: Buffer[] = [];
|
||||||
const proc = spawn(command, {
|
const proc = spawn(command, {
|
||||||
stdio: ["inherit", "pipe", "inherit"],
|
stdio: ["inherit", "pipe", "pipe"],
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
proc.stdout.on("data", (x) => {
|
proc.stdout.on("data", (x) => {
|
||||||
@ -80,6 +84,11 @@ export async function sh(command: string): Promise<string> {
|
|||||||
throw Error("unexpected data chunk type");
|
throw Error("unexpected data chunk type");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const stderrLogFileName = path.join(t.testDir, `${logName}-stderr.log`);
|
||||||
|
const stderrLog = fs.createWriteStream(stderrLogFileName, {
|
||||||
|
flags: "a",
|
||||||
|
});
|
||||||
|
proc.stderr.pipe(stderrLog);
|
||||||
proc.on("exit", (code) => {
|
proc.on("exit", (code) => {
|
||||||
console.log("child process exited");
|
console.log("child process exited");
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
@ -113,22 +122,6 @@ export class ProcessWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeTempDir(): Promise<string> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
fs.mkdtemp(
|
|
||||||
path.join(os.tmpdir(), "taler-integrationtest-"),
|
|
||||||
(err, directory) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(directory);
|
|
||||||
console.log(directory);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CoinConfig {
|
interface CoinConfig {
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
@ -620,13 +613,6 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
|
|
||||||
fs.writeFileSync(masterPrivFile, Buffer.from(exchangeMasterKey.eddsaPriv));
|
fs.writeFileSync(masterPrivFile, Buffer.from(exchangeMasterKey.eddsaPriv));
|
||||||
|
|
||||||
console.log("writing key to", masterPrivFile);
|
|
||||||
console.log("pub is", talerCrypto.encodeCrock(exchangeMasterKey.eddsaPub));
|
|
||||||
console.log(
|
|
||||||
"priv is",
|
|
||||||
talerCrypto.encodeCrock(exchangeMasterKey.eddsaPriv),
|
|
||||||
);
|
|
||||||
|
|
||||||
const cfgFilename = gc.testDir + `/exchange-${e.name}.conf`;
|
const cfgFilename = gc.testDir + `/exchange-${e.name}.conf`;
|
||||||
config.write(cfgFilename);
|
config.write(cfgFilename);
|
||||||
return new ExchangeService(gc, e, cfgFilename, exchangeMasterKey);
|
return new ExchangeService(gc, e, cfgFilename, exchangeMasterKey);
|
||||||
@ -873,14 +859,29 @@ function shouldLinger(): boolean {
|
|||||||
return process.env["TALER_TEST_KEEP"] == "1";
|
return process.env["TALER_TEST_KEEP"] == "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCurrentSymlink(testDir: string): void {
|
||||||
|
const currLink = path.join(os.tmpdir(), "taler-integrationtest-current");
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(currLink);
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
fs.symlinkSync(currLink, testDir);
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function runTest(testMain: (gc: GlobalTestState) => Promise<void>) {
|
export function runTest(testMain: (gc: GlobalTestState) => Promise<void>) {
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
let gc: GlobalTestState | undefined;
|
let gc: GlobalTestState | undefined;
|
||||||
let ret = 0;
|
let ret = 0;
|
||||||
try {
|
try {
|
||||||
gc = new GlobalTestState({
|
gc = new GlobalTestState({
|
||||||
testDir: await makeTempDir(),
|
testDir: fs.mkdtempSync("taler-integrationtest-"),
|
||||||
});
|
});
|
||||||
|
updateCurrentSymlink(gc.testDir);
|
||||||
await testMain(gc);
|
await testMain(gc);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("FATAL: test failed with exception", e);
|
console.error("FATAL: test failed with exception", e);
|
||||||
@ -915,6 +916,8 @@ export class WalletCli {
|
|||||||
): Promise<walletCoreApi.CoreApiResponse> {
|
): Promise<walletCoreApi.CoreApiResponse> {
|
||||||
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
||||||
const resp = await sh(
|
const resp = await sh(
|
||||||
|
this.globalTestState,
|
||||||
|
"wallet",
|
||||||
`taler-wallet-cli --no-throttle --wallet-db '${wdb}' api '${request}' ${shellWrap(
|
`taler-wallet-cli --no-throttle --wallet-db '${wdb}' api '${request}' ${shellWrap(
|
||||||
JSON.stringify(payload),
|
JSON.stringify(payload),
|
||||||
)}`,
|
)}`,
|
||||||
@ -926,12 +929,18 @@ export class WalletCli {
|
|||||||
async runUntilDone(): Promise<void> {
|
async runUntilDone(): Promise<void> {
|
||||||
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
||||||
await sh(
|
await sh(
|
||||||
|
this.globalTestState,
|
||||||
|
"wallet",
|
||||||
`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-until-done`,
|
`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-until-done`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async runPending(): Promise<void> {
|
async runPending(): Promise<void> {
|
||||||
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
const wdb = this.globalTestState.testDir + "/walletdb.json";
|
||||||
await sh(`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-pending`);
|
await sh(
|
||||||
|
this.globalTestState,
|
||||||
|
"wallet",
|
||||||
|
`taler-wallet-cli --no-throttle --wallet-db ${wdb} run-pending`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user