Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

failed to open json report file #13

Open
alexgocariq opened this issue Jun 7, 2022 · 4 comments
Open

failed to open json report file #13

alexgocariq opened this issue Jun 7, 2022 · 4 comments

Comments

@alexgocariq
Copy link

Have the following version of the artillery:
`VERSION INFO:

Artillery Core: 2.0.0-18
Artillery Pro: not installed (https://artillery.io/product)

Node.js: v18.0.0
OS: darwin`

Ran test and generated json file.
Start report viewer and loaded the file, got this error on UI.
Error loading report file. Please verify the json file is complete.

@N-ickJones
Copy link

N-ickJones commented Jun 10, 2022

I changed the utilities mapper.ts to the following and it is working with artillery v2. Updated to include data label parsing fix

/* public */

const mapToLegacyObject = (src) => {
  return {
    aggregate: _mapToLegacyBaseLevelObject(src.aggregate),
    intermediate: _mapToLegacyIntermediate(src)
  };
};

/* Private */

const _mapToLegacyBaseLevelObject = (src) => {
  return {
    timestamp: new Date(getIntegerDate(src.period)),
    scenariosCreated:
      src.counters["vusers.created"] ||
      src.counters["core.vusers.created.total"] ||
      0,
    scenariosCompleted:
      src.counters["vusers.completed"] ||
      src.counters["core.vusers.completed"] ||
      0,
    scenariosAvoided:
      src.counters["vusers.skipped"] ||
      src.counters["core.vusers.skipped"] ||
      0,
    requestsCompleted:
      src.counters["http.responses"] ||
      src.counters["engine.http.responses"] ||
      src.counters["engine.socketio.emit"] ||
      src.counters["engine.websocket.messages_sent"] ||
      0,
    latency: _mapToLegacyLatency(src),
    rps: {
      mean: src.rates
        ? src.rates["http.request_rate"] ||
        src.rates["engine.http.response_rate"] ||
        src.rates["engine.socketio.emit_rate"] ||
        0
        : 0,
      count:
        src.counters["http.responses"] ||
        src.counters["engine.http.responses"] ||
        src.counters["engine.socketio.emit"] ||
        0
    },
    codes: _mapToLegacyCodes(src),
    errors: _mapToLegacyErrors(src),
    phases: _mapToLegacyPhases(src)
  };
};

const _mapToLegacyLatency = (src_in) => {
  var src = src_in.summaries
  var selector = "";
  if (src["http.response_time"]) {
    selector = "http.response_time";
  }
  else if (src["engine.http.response_time"]) {
    selector = "engine.http.response_time";
  }
  else if (src["engine.http.socketio"]) {
    selector = "engine.http.socketio";
  }
  else {
    throw new Error("Unable to Parse Latency")
  }

  return {
    min: src[selector].min || 0,
    max: src[selector].max || 0,
    median: src[selector].median || 0,
    p50: src[selector].median || 0,
    p95: src[selector].p95 || 0,
    p99: src[selector].p99 || 0
  };
};

const _mapToLegacyCodes = (src) => {
  var propNameHttp = "http.codes.";
  //var propNameHttp = "engine.http.codes.";
  var propNameSocket = "engine.socketio.codes.";
  var dest = {};
  for (var prop in src.counters) {
    if (prop.startsWith(propNameHttp)) {
      dest[prop.replace(propNameHttp, "")] = src.counters[prop];
    }
    if (prop.startsWith(propNameSocket)) {
      dest[prop.replace(propNameSocket, "")] = src.counters[prop];
    }
  }
  return dest;
};

const _mapToLegacyErrors = (src) => {
  var propName = "errors.";
  var dest = {};
  for (var prop in src.counters) {
    if (prop.startsWith(propName)) {
      dest[prop.replace(propName, "")] = src.counters[prop];
    }
  }
  return dest;
};

const _mapToLegacyIntermediate = (src) => {
  var dest = [];
  src.intermediate.forEach((inter) => {
    dest.push(_mapToLegacyBaseLevelObject(inter));
  });
  return dest;
};

// @ts-ignore
const _mapToLegacyPhases = (src) => {
  return [];
};

const getIntegerDate = (period: any) => {
  if (typeof period === 'string') {
    return parseInt(period);
  }
  else if (typeof period === 'number') {
    return period;
  }
  else {
    throw new Error('invalid type for property period')
  }
}

export {
  mapToLegacyObject
};

@alexgocariq
Copy link
Author

alexgocariq commented Jun 13, 2022

Thanks for fixing the problem, when it will be available?

@cmg-george
Copy link

I also have the same problem with:

Artillery Core: 2.0.0-20
Artillery Pro:  not installed (https://artillery.io/product)

Node.js: v16.13.1
OS:      win32

and the above fix did not work.

@kevincerda
Copy link

kevincerda commented Jul 13, 2022

It appears this error occurs when the request times out and returns a ETIMEDOUT error.

I was able to get my reports to load by updating the _mapToLegacyLatency function in mappers.ts

`const _mapToLegacyLatency = (src_in) => {
const src = src_in.summaries

const vals = src[Object.keys(src)[0]] || null;

return {
min: vals ? vals.min : 0,
max: vals ? vals.max : 0,
median: vals ? vals.median : 0,
p50: vals ? vals.median : 0,
p95: vals ? vals.p95 : 0,
p99: vals ? vals.p99 : 0
};
};`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants