Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Feb 23, 2024
1 parent 11ba151 commit 021b102
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ export const finalSignificantItemGroups: SignificantItemGroup[] = [
fieldValue: 'login.php',
docCount: 790,
pValue: 0.012783309213417932,
duplicate: 1,
duplicate: 2,
},
],
docCount: 790,
pValue: 0.012783309213417932,
},
{
id: '1807570559',
id: '2091742187',
group: [
{
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 792,
pValue: 0.012783309213417932,
pValue: 0.00974308761016614,
duplicate: 2,
},
{
Expand All @@ -76,11 +76,36 @@ export const finalSignificantItemGroups: SignificantItemGroup[] = [
fieldName: 'user',
fieldValue: 'Peter',
docCount: 636,
pValue: 0.012783309213417932,
duplicate: 1,
pValue: 0.00974308761016614,
duplicate: 2,
},
],
docCount: 636,
pValue: 0.00974308761016614,
},
{
id: '1937394803',
group: [
{
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
docCount: 790,
pValue: 0.012783309213417932,
duplicate: 2,
},
{
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
docCount: 632,
pValue: 0.012783309213417932,
duplicate: 2,
},
],
docCount: 632,
pValue: 0.012783309213417932,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const frequentItemSets: ItemSet[] = [
{
set: [
{ fieldName: 'user', fieldValue: 'Peter' },
{ fieldName: 'url', fieldValue: 'home.php' },
{ fieldName: 'url', fieldValue: 'login.php' },
],
size: 2,
maxPValue: 0.012783309213417932,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/aiops/common/api/stream_reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('streamReducer', () => {
);

expect(state2.significantItems).toHaveLength(4);
expect(state2.significantItemsGroups).toHaveLength(3);
expect(state2.significantItemsGroups).toHaveLength(4);

const state3 = streamReducer(state2, resetGroupsAction());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,85 +15,108 @@ describe('getGroupTableItems', () => {

expect(groupTableItems).toEqual([
{
id: '2675980076',
docCount: 792,
pValue: 0.00974308761016614,
uniqueItemsCount: 0,
groupItemsSortedByUniqueness: [
{
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
docCount: 792,
duplicate: 2,
pValue: 0.012783309213417932,
duplicate: 2,
},
{
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 792,
duplicate: 2,
pValue: 0.00974308761016614,
duplicate: 2,
},
],
histogram: undefined,
id: '2675980076',
pValue: 0.00974308761016614,
uniqueItemsCount: 0,
},
{
id: '3819687732',
docCount: 790,
pValue: 0.012783309213417932,
uniqueItemsCount: 0,
groupItemsSortedByUniqueness: [
{
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
docCount: 790,
duplicate: 1,
pValue: 0.012783309213417932,
duplicate: 2,
},
{
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
docCount: 792,
duplicate: 2,
pValue: 0.012783309213417932,
duplicate: 2,
},
],
histogram: undefined,
id: '3819687732',
pValue: 0.012783309213417932,
uniqueItemsCount: 1,
},
{
id: '2091742187',
docCount: 636,
pValue: 0.00974308761016614,
uniqueItemsCount: 0,
groupItemsSortedByUniqueness: [
{
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
docCount: 636,
duplicate: 1,
pValue: 0.012783309213417932,
pValue: 0.00974308761016614,
duplicate: 2,
},
{
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 792,
pValue: 0.00974308761016614,
duplicate: 2,
pValue: 0.012783309213417932,
},
],
histogram: undefined,
id: '1807570559',
},
{
id: '1937394803',
docCount: 632,
pValue: 0.012783309213417932,
uniqueItemsCount: 1,
uniqueItemsCount: 0,
groupItemsSortedByUniqueness: [
{
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
docCount: 632,
pValue: 0.012783309213417932,
duplicate: 2,
},
{
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
docCount: 790,
pValue: 0.012783309213417932,
duplicate: 2,
},
],
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('getValueCounts', () => {
});

it('get value counts for field url', () => {
expect(getValueCounts(frequentItemSets, 'url')).toEqual({ 'home.php': 3, 'login.php': 1 });
expect(getValueCounts(frequentItemSets, 'url')).toEqual({ 'home.php': 2, 'login.php': 2 });
});

it('get value counts for field user', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export default ({ getService }: FtrProviderContext) => {

expect(orderBy(groups, ['docCount'], ['desc'])).to.eql(
orderBy(testData.expected.groups, ['docCount'], ['desc']),
'Grouping result does not match expected values.'
`Grouping result does not match expected values. Expected ${JSON.stringify(
testData.expected.groups
)}, got ${JSON.stringify(groups)}`
);

const groupHistogramActions = getGroupHistogramActions(data, apiVersion);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/aiops/test_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const getLogRateAnalysisTestData = <T extends ApiVersion>(): Array<TestDa
deviationMin: 1561986810992,
end: 2147483647000,
index: 'ft_ecommerce',
searchQuery: '{"bool":{"filter":[],"must":[{"match_all":{}}],"must_not":[]}}',
searchQuery: '{"match_all":{}}',
start: 0,
timeFieldName: 'order_date',
grouping: true,
Expand Down

0 comments on commit 021b102

Please sign in to comment.