Tests a scenario where all keys are removed, and one
where a key is ignored.
Signed-off-by: Laura Flores <lflores@redhat.com>
});
});
+ it('should remove perf channel fields from a report', () => {
+ expect(
+ JSON.parse(
+ component.formatReportTest({
+ perf_counters: {},
+ stats_per_pool: {},
+ stats_per_pg: {},
+ io_rate: {},
+ osd_perf_histograms: {},
+ mempool: {},
+ heap_stats: {},
+ rocksdb_stats: {}
+ })
+ )
+ ).toStrictEqual({});
+
+ expect(
+ JSON.parse(
+ component.formatReportTest({
+ perf_counters: {},
+ stats_per_pool: {},
+ stats_per_pg: {},
+ io_rate: {},
+ osd_perf_histograms: {},
+ mempool: {},
+ heap_stats: {},
+ rocksdb_stats: {},
+ other: {}
+ })
+ )
+ ).toStrictEqual({
+ other: {}
+ });
+ });
+
it('should submit', () => {
component.onSubmit();
const req = httpTesting.expectOne('api/telemetry');
return JSON.stringify(copy, null, 2);
}
+ formatReportTest(report: object) {
+ let copy = {};
+ copy = JSON.parse(JSON.stringify(report));
+ const perf_keys = [
+ 'perf_counters',
+ 'stats_per_pool',
+ 'stats_per_pg',
+ 'io_rate',
+ 'osd_perf_histograms',
+ 'mempool',
+ 'heap_stats',
+ 'rocksdb_stats'
+ ];
+ for (let i = 0; i < perf_keys.length; i++) {
+ const key = perf_keys[i];
+ if (key in copy) {
+ delete copy[key];
+ }
+ }
+ return JSON.stringify(copy, null, 2);
+ }
+
private createPreviewForm() {
const controls = {
report: this.formatReport(),