Skip to content

Commit

Permalink
fix formatting and increase maxSizeBytes for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Mar 15, 2021
1 parent 81d54bf commit f183650
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ export class CsvGenerator {
}

private formatCellValues(formatters: Record<string, FieldFormat>) {
return ({ column: tableColumn, data: dataTableCell }: { column: string; data: any }) => {
let cell: string[] | string;
// guard against _score, _type, etc
return ({
column: tableColumn,
data: dataTableCell,
}: {
column: string;
data: any;
}): string => {
let cell: string[] | string | object;
// check truthiness to guard against _score, _type, etc
if (tableColumn && dataTableCell) {
try {
cell = formatters[tableColumn].convert(dataTableCell);
Expand All @@ -179,7 +185,12 @@ export class CsvGenerator {
// We have to strip singular array values out of their array wrapper,
// So that the value appears the visually the same as seen in Discover
if (Array.isArray(cell)) {
cell = cell.join(', '); // mimic Discover behavior
cell = cell.map((c) => (typeof c === 'object' ? JSON.stringify(c) : c)).join(', ');
}

// Check for object-type value (geoip)
if (typeof cell === 'object') {
cell = JSON.stringify(cell);
}

return cell;
Expand Down Expand Up @@ -235,7 +246,7 @@ export class CsvGenerator {
.join(settings.separator) + '\n';

if (!builder.tryAppend(row)) {
this.logger.warn('max Size Reached');
this.logger.warn(`Max Size Reached after ${this.csvRowCount} rows.`);
this.maxSizeReached = true;
if (this.cancellationToken) {
this.cancellationToken.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
`--server.maxPayloadBytes=1679958`,
`--server.port=${kbnTestConfig.getPort()}`,
`--xpack.reporting.capture.maxAttempts=1`,
`--xpack.reporting.csv.maxSizeBytes=2850`,
`--xpack.reporting.csv.maxSizeBytes=6000`,
`--xpack.reporting.queue.pollInterval=3000`,
`--xpack.security.session.idleTimeout=3600000`,
`--xpack.reporting.capture.networkPolicy.rules=${JSON.stringify(testPolicyRules)}`,
Expand Down
Loading

0 comments on commit f183650

Please sign in to comment.