Skip to content

Commit

Permalink
fix(fargate): convert to posix paths before sending files to s3 (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobridge authored Feb 2, 2024
1 parent 1b6220c commit e359bd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion packages/artillery/lib/platform/aws-ecs/legacy/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const Table = require('cli-table3');

// NOTE: Code below presumes that all paths are absolute

//Tests in Fargate run on ubuntu, which uses posix paths
//This function converts a path to posix path, in case the original path was not posix (e.g. windows runs)
function _convertToPosixPath(p) {
return p.split(path.sep).join(path.posix.sep);
}

function createBOM(absoluteScriptPath, extraFiles, opts, callback) {
A.waterfall(
[
Expand Down Expand Up @@ -70,6 +76,7 @@ function createBOM(absoluteScriptPath, extraFiles, opts, callback) {
prefix = commonPrefix(context.localFilePaths);
}

prefix = _convertToPosixPath(prefix);
debug('prefix', prefix);

//
Expand Down Expand Up @@ -100,7 +107,15 @@ function createBOM(absoluteScriptPath, extraFiles, opts, callback) {
});

const files = context.localFilePaths.map((p) => {
return { orig: p, noPrefix: p.substring(prefix.length, p.length) };
return {
orig: p,
noPrefix: p.substring(prefix.length, p.length),
origPosix: _convertToPosixPath(p),
noPrefixPosix: _convertToPosixPath(p).substring(
prefix.length,
p.length
)
};
});

const pkgPath = _.find(files, (f) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/artillery/lib/platform/aws-ecs/legacy/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function syncS3(context, callback) {
return eachDone(null, context);
}

const key = context.s3Prefix + '/' + item.noPrefix;
const key = context.s3Prefix + '/' + item.noPrefixPosix;
plainS3.putObject(
{
Bucket: context.s3Bucket,
Expand Down Expand Up @@ -166,13 +166,13 @@ function writeTestMetadata(context, callback) {
const res = context.manifest.files.filter((o) => {
return o.orig === context.configPath;
});
const newConfigPath = res[0].noPrefix; // if we have been given a config, we must have an entry
const newConfigPath = res[0].noPrefixPosix; // if we have been given a config, we must have an entry
metadata.configPath = newConfigPath;
}

const newScriptPath = context.manifest.files.filter((o) => {
return o.orig === context.scriptPath;
})[0].noPrefix;
})[0].noPrefixPosix;
metadata.scriptPath = newScriptPath;

debug('metadata', metadata);
Expand Down

0 comments on commit e359bd2

Please sign in to comment.