Skip to content

Commit

Permalink
rename gaps to zerodocsfallback
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Nov 29, 2023
1 parent 8c5c3f6 commit fcfffc6
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 88 deletions.
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisGroupsTableNotextfieldNogaps = [
export const analysisGroupsTable = [
{
group: 'response_code: 500url: home.php',
docCount: '792',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisGroupsTableTextfieldNogaps = [
export const analysisGroupsTableTextfield = [
{
group: 'message: an unexpected error occuredurl: home.phpresponse_code: 500',
docCount: '634',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisGroupsTableTextfieldGaps = [
export const analysisGroupsTableTextfieldZerodocsfallback = [
{
group:
'message: an unexpected error occuredurl: home.phpuser: Maryresponse_code: 500version: v1.0.0',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisGroupsTableNotextfieldGaps = [
export const analysisGroupsTableZerodocsfallback = [
{ group: 'response_code: 500url: home.phpuser: Maryversion: v1.0.0', docCount: '47' },
{ group: 'response_code: 500url: home.phpuser: Paulversion: v1.0.0', docCount: '59' },
{ group: 'response_code: 500url: login.phpuser: Maryversion: v1.0.0', docCount: '35' },
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisTableNotextfieldNogaps = [
export const analysisTable = [
{
fieldName: 'url',
fieldValue: 'home.php',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisTableTextfieldNogaps = [
export const analysisTableTextfield = [
{
fieldName: 'message',
fieldValue: 'an unexpected error occured',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisTableTextfieldGaps = [
export const analysisTableTextfieldZerodocsfallback = [
{
fieldName: 'message',
fieldValue: 'Paul [11/19/2022, 9:00:34 AM] "GET /home.php HTTP/1.1" 200',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const analysisTableNotextfieldGaps = [
export const analysisTableZerodocsfallback = [
{
fieldName: 'response_code',
fieldValue: '500',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const filteredAnalysisGroupsTableNotextfieldNogaps = [
export const filteredAnalysisGroupsTable = [
{ group: '* url: home.phpresponse_code: 500', docCount: '792' },
{ group: '* url: login.phpresponse_code: 500', docCount: '790' },
];
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const filteredAnalysisGroupsTableTextfieldNogaps = [
export const filteredAnalysisGroupsTableTextfield = [
{
group: '* url: home.phpmessage: an unexpected error occuredresponse_code: 500',
docCount: '634',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const filteredAnalysisGroupsTableTextfieldGaps = [
export const filteredAnalysisGroupsTableTextfieldZerodocsfallback = [
{
group: 'message: an unexpected error occuredurl: home.phpresponse_code: 500version: v1.0.0',
docCount: '58',
Expand Down
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

export const filteredAnalysisGroupsTableNotextfieldGaps = [
export const filteredAnalysisGroupsTableZerodocsfallback = [
{ group: 'url: home.phpresponse_code: 200version: v1.0.0', docCount: '46' },
{ group: 'url: home.phpresponse_code: 404version: v1.0.0', docCount: '63' },
{ group: 'url: home.phpresponse_code: 500version: v1.0.0', docCount: '106' },
Expand Down
Expand Up @@ -11,18 +11,18 @@ import type { TestData } from '../../types';

import type { LogRateAnalysisDataGenerator } from '../../../../services/aiops/log_rate_analysis_data_generator';

import { analysisGroupsTableTextfieldGaps } from './__mocks__/analysis_groups_table_textfield_gaps';
import { analysisGroupsTableNotextfieldGaps } from './__mocks__/analysis_groups_table_notextfield_gaps';
import { analysisGroupsTableTextfieldNogaps } from './__mocks__/analysis_groups_table_textfield_nogaps';
import { analysisGroupsTableNotextfieldNogaps } from './__mocks__/analysis_groups_table_notextfield_nogaps';
import { filteredAnalysisGroupsTableTextfieldGaps } from './__mocks__/filtered_analysis_groups_table_textfield_gaps';
import { filteredAnalysisGroupsTableNotextfieldGaps } from './__mocks__/filtered_analysis_groups_table_notextfield_gaps';
import { filteredAnalysisGroupsTableTextfieldNogaps } from './__mocks__/filtered_analysis_groups_table_textfield_nogaps';
import { filteredAnalysisGroupsTableNotextfieldNogaps } from './__mocks__/filtered_analysis_groups_table_notextfield_nogaps';
import { analysisTableTextfieldGaps } from './__mocks__/analysis_table_textfield_gaps';
import { analysisTableNotextfieldGaps } from './__mocks__/analysis_table_notextfield_gaps';
import { analysisTableTextfieldNogaps } from './__mocks__/analysis_table_textfield_nogaps';
import { analysisTableNotextfieldNogaps } from './__mocks__/analysis_table_notextfield_nogaps';
import { analysisGroupsTableTextfieldZerodocsfallback } from './__mocks__/analysis_groups_table_textfield_zerodocsfallback';
import { analysisGroupsTableZerodocsfallback } from './__mocks__/analysis_groups_table_zerodocsfallback';
import { analysisGroupsTableTextfield } from './__mocks__/analysis_groups_table_textfield';
import { analysisGroupsTable } from './__mocks__/analysis_groups_table';
import { filteredAnalysisGroupsTableTextfieldZerodocsfallback } from './__mocks__/filtered_analysis_groups_table_textfield_zerodocsfallback';
import { filteredAnalysisGroupsTableZerodocsfallback } from './__mocks__/filtered_analysis_groups_table_zerodocsfallback';
import { filteredAnalysisGroupsTableTextfield } from './__mocks__/filtered_analysis_groups_table_textfield';
import { filteredAnalysisGroupsTable } from './__mocks__/filtered_analysis_groups_table';
import { analysisTableTextfieldZerodocsfallback } from './__mocks__/analysis_table_textfield_zerodocsfallback';
import { analysisTableZerodocsfallback } from './__mocks__/analysis_table_zerodocsfallback';
import { analysisTableTextfield } from './__mocks__/analysis_table_textfield';
import { analysisTable } from './__mocks__/analysis_table';

const REFERENCE_TS = 1669018354793;
const DAY_MS = 86400000;
Expand All @@ -33,43 +33,43 @@ const BASELINE_TS = DEVIATION_TS - DAY_MS * 1;
interface GetArtificialLogDataViewTestDataOptions {
analysisType: LogRateAnalysisType;
textField: boolean;
gaps: boolean;
zeroDocsFallback: boolean;
}

export const getArtificialLogDataViewTestData = ({
analysisType,
textField,
gaps,
zeroDocsFallback,
}: GetArtificialLogDataViewTestDataOptions): TestData => {
function getAnalysisGroupsTable() {
if (gaps) {
return textField ? analysisGroupsTableTextfieldGaps : analysisGroupsTableNotextfieldGaps;
if (zeroDocsFallback) {
return textField
? analysisGroupsTableTextfieldZerodocsfallback
: analysisGroupsTableZerodocsfallback;
}
return textField ? analysisGroupsTableTextfieldNogaps : analysisGroupsTableNotextfieldNogaps;
return textField ? analysisGroupsTableTextfield : analysisGroupsTable;
}

function getFilteredAnalysisGroupsTable() {
if (gaps) {
if (zeroDocsFallback) {
return textField
? filteredAnalysisGroupsTableTextfieldGaps
: filteredAnalysisGroupsTableNotextfieldGaps;
? filteredAnalysisGroupsTableTextfieldZerodocsfallback
: filteredAnalysisGroupsTableZerodocsfallback;
}

return textField
? filteredAnalysisGroupsTableTextfieldNogaps
: filteredAnalysisGroupsTableNotextfieldNogaps;
return textField ? filteredAnalysisGroupsTableTextfield : filteredAnalysisGroupsTable;
}

function getAnalysisTable() {
if (gaps) {
return textField ? analysisTableTextfieldGaps : analysisTableNotextfieldGaps;
if (zeroDocsFallback) {
return textField ? analysisTableTextfieldZerodocsfallback : analysisTableZerodocsfallback;
}

return textField ? analysisTableTextfieldNogaps : analysisTableNotextfieldNogaps;
return textField ? analysisTableTextfield : analysisTable;
}

function getFieldSelectorPopover() {
if (gaps) {
if (zeroDocsFallback) {
return [...(textField ? ['message'] : []), 'response_code', 'url', 'user', 'version'];
}
return [...(textField ? ['message'] : []), 'response_code', 'url', 'user'];
Expand All @@ -78,29 +78,29 @@ export const getArtificialLogDataViewTestData = ({
function getSuiteTitle() {
return `artificial logs with ${analysisType} and ${
textField ? 'text field' : 'no text field'
} and ${gaps ? 'gaps' : 'no gaps'}`;
} and ${zeroDocsFallback ? 'zero docs fallback' : 'no zero docs fallback'}`;
}

function getDataGenerator(): LogRateAnalysisDataGenerator {
return `artificial_logs_with_${analysisType}_${textField ? 'textfield' : 'notextfield'}_${
gaps ? 'gaps' : 'nogaps'
return `artificial_logs_with_${analysisType}${textField ? '_textfield' : ''}${
zeroDocsFallback ? '_zerodocsfallback' : ''
}`;
}

function getBrushBaselineTargetTimestamp() {
if (analysisType === 'dip' && gaps) {
if (analysisType === 'dip' && zeroDocsFallback) {
return DEVIATION_TS;
}

return gaps ? BASELINE_TS - DAY_MS / 2 : BASELINE_TS + DAY_MS / 2;
return zeroDocsFallback ? BASELINE_TS - DAY_MS / 2 : BASELINE_TS + DAY_MS / 2;
}

function getBrushDeviationTargetTimestamp() {
if (analysisType === 'dip' && gaps) {
if (analysisType === 'dip' && zeroDocsFallback) {
return DEVIATION_TS + DAY_MS * 1.5;
}

return gaps ? DEVIATION_TS : DEVIATION_TS + DAY_MS / 2;
return zeroDocsFallback ? DEVIATION_TS : DEVIATION_TS + DAY_MS / 2;
}

return {
Expand All @@ -111,12 +111,12 @@ export const getArtificialLogDataViewTestData = ({
sourceIndexOrSavedSearch: getDataGenerator(),
brushBaselineTargetTimestamp: getBrushBaselineTargetTimestamp(),
brushDeviationTargetTimestamp: getBrushDeviationTargetTimestamp(),
brushIntervalFactor: gaps ? 1 : 10,
brushIntervalFactor: zeroDocsFallback ? 1 : 10,
chartClickCoordinates: [-200, 30],
fieldSelectorSearch: 'user',
fieldSelectorApplyAvailable: true,
expected: {
totalDocCountFormatted: gaps ? '9,482' : '8,400',
totalDocCountFormatted: zeroDocsFallback ? '9,482' : '8,400',
analysisGroupsTable: getAnalysisGroupsTable(),
filteredAnalysisGroupsTable: getFilteredAnalysisGroupsTable(),
analysisTable: getAnalysisTable(),
Expand Down
16 changes: 8 additions & 8 deletions x-pack/test/functional/apps/aiops/log_rate_analysis_test_data.ts
Expand Up @@ -21,41 +21,41 @@ export const logRateAnalysisTestData: TestData[] = [
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE,
textField: false,
gaps: false,
zeroDocsFallback: false,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE,
textField: true,
gaps: false,
zeroDocsFallback: false,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.DIP,
textField: false,
gaps: false,
zeroDocsFallback: false,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.DIP,
textField: true,
gaps: false,
zeroDocsFallback: false,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE,
textField: true,
gaps: true,
zeroDocsFallback: true,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.SPIKE,
textField: false,
gaps: true,
zeroDocsFallback: true,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.DIP,
textField: true,
gaps: true,
zeroDocsFallback: true,
}),
getArtificialLogDataViewTestData({
analysisType: LOG_RATE_ANALYSIS_TYPE.DIP,
textField: false,
gaps: true,
zeroDocsFallback: true,
}),
];

0 comments on commit fcfffc6

Please sign in to comment.