fix(test): use dynamic Cloudly test port
This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
import { Qenv } from '@push.rocks/qenv';
|
||||
import { SmartNetwork } from '@push.rocks/smartnetwork';
|
||||
import { tapNodeTools } from '@git.zone/tstest/tapbundle_node';
|
||||
|
||||
const testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
import * as cloudly from '../../ts/index.js';
|
||||
|
||||
const stopFunctions: Array<() => Promise<void>> = [];
|
||||
|
||||
const tapToolsNodeMod = await import('@git.zone/tstest/tapbundle_node');
|
||||
const smartmongo = await tapToolsNodeMod.tapNodeTools.createSmartmongo();
|
||||
const getPublicPort = async () => {
|
||||
if (process.env.SERVEZONE_TEST_PORT) {
|
||||
return process.env.SERVEZONE_TEST_PORT;
|
||||
}
|
||||
const smartnetwork = new SmartNetwork();
|
||||
const publicPort = await smartnetwork.findFreePort(30000, 40000, { randomize: true });
|
||||
if (!publicPort) {
|
||||
throw new Error('Could not find a free Cloudly test port in range 30000-40000');
|
||||
}
|
||||
return String(publicPort);
|
||||
};
|
||||
|
||||
const smartmongo = await tapNodeTools.createSmartmongo();
|
||||
stopFunctions.push(async () => {
|
||||
await smartmongo.stopAndDumpToDir('./.nogit/mongodump');
|
||||
});
|
||||
const smarts3 = await tapToolsNodeMod.tapNodeTools.createSmarts3();
|
||||
const smarts3 = await tapNodeTools.createSmarts3();
|
||||
await smarts3.createBucket('cloudly_test_bucket');
|
||||
stopFunctions.push(async () => {
|
||||
await smarts3.stop();
|
||||
@@ -21,7 +35,7 @@ export const testCloudlyConfig: cloudly.ICloudlyConfig = {
|
||||
environment: 'integration',
|
||||
letsEncryptEmail: 'test@serve.zone',
|
||||
publicUrl: '127.0.0.1',
|
||||
publicPort: '8080',
|
||||
publicPort: await getPublicPort(),
|
||||
mongoDescriptor: await smartmongo.getMongoDescriptor(),
|
||||
s3Descriptor: await smarts3.getS3Descriptor({
|
||||
bucketName: 'cloudly_test_bucket'
|
||||
@@ -36,7 +50,7 @@ export const testCloudlyConfig: cloudly.ICloudlyConfig = {
|
||||
})(),
|
||||
};
|
||||
|
||||
await tapToolsNodeMod.tapNodeTools.testFileProvider.getDockerAlpineImageAsLocalTarball();
|
||||
await tapNodeTools.testFileProvider.getDockerAlpineImageAsLocalTarball();
|
||||
|
||||
export const createCloudly = async () => {
|
||||
const cloudlyInstance = new cloudly.Cloudly(testCloudlyConfig);
|
||||
|
||||
Reference in New Issue
Block a user