report-viewer icon indicating copy to clipboard operation
report-viewer copied to clipboard

failed to open json report file

Open alexgocariq opened this issue 3 years ago • 4 comments

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.

alexgocariq avatar Jun 07 '22 07:06 alexgocariq

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
};

N-ickJones avatar Jun 10 '22 19:06 N-ickJones

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

alexgocariq avatar Jun 13 '22 15:06 alexgocariq

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.

cmg-george avatar Jul 08 '22 06:07 cmg-george

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 }; };`

kevincerda avatar Jul 13 '22 18:07 kevincerda