fix: Fixes to cloud benchmarks (no-changelog) (#10634)

This commit is contained in:
Tomi Turtiainen
2024-09-02 14:58:24 +03:00
committed by GitHub
parent 56354151d4
commit afc4d4e144
19 changed files with 272 additions and 45 deletions

View File

@@ -20,6 +20,9 @@ export class TerraformClient {
/**
* @typedef {Object} BenchmarkEnv
* @property {string} vmName
* @property {string} ip
* @property {string} sshUsername
* @property {string} sshPrivateKeyPath
*
* @returns {Promise<BenchmarkEnv>}
*/
@@ -27,9 +30,14 @@ export class TerraformClient {
console.log('Provisioning cloud environment...');
await this.$$`terraform init`;
await this.$$`terraform apply -input=false -auto-approve`;
// await this.$$`terraform apply -input=false -auto-approve`;
const privateKeyName = await this.extractPrivateKey();
return {
ip: await this.getTerraformOutput('ip'),
sshUsername: await this.getTerraformOutput('ssh_username'),
sshPrivateKeyPath: path.join(paths.infraCodeDir, privateKeyName),
vmName: await this.getTerraformOutput('vm_name'),
};
}
@@ -42,11 +50,18 @@ export class TerraformClient {
console.log('Destroying cloud environment...');
await this.$$`terraform destroy -input=false -auto-approve`;
// await this.$$`terraform destroy -input=false -auto-approve`;
}
async getTerraformOutput(key) {
const output = await this.$$`terraform output -raw ${key}`;
return output.stdout.trim();
}
async extractPrivateKey() {
await this.$$`terraform output -raw ssh_private_key > privatekey.pem`;
await this.$$`chmod 600 privatekey.pem`;
return 'privatekey.pem';
}
}