-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite Grok Debugger Tests to use Standard Functional Test Runner (#…
…108301) * Converted Grok debugger tests to use standard functional test runner practices. * Fixed last test. * Removed old test now that the new test is passing. * Fixed condition for retry. * Removed .only to restore test run. * fixed errors * Fixed nits.
- Loading branch information
John Dorlus
authored
Aug 17, 2021
1 parent
3ab111e
commit 9aa1705
Showing
4 changed files
with
194 additions
and
100 deletions.
There are no files selected for viewing
89 changes: 0 additions & 89 deletions
89
x-pack/test/functional/apps/grok_debugger/grok_debugger.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default ({ getPageObjects, getService }: FtrProviderContext) => { | ||
const PageObjects = getPageObjects(['common', 'grokDebugger']); | ||
const browser = getService('browser'); | ||
const security = getService('security'); | ||
const testSubjects = getService('testSubjects'); | ||
const retry = getService('retry'); | ||
|
||
describe('Grok Debugger', function () { | ||
before(async () => { | ||
// Increase window height to ensure "Simulate" button is shown above the | ||
// fold. Otherwise it can't be clicked by the browser driver. | ||
await browser.setWindowSize(1600, 1000); | ||
await security.testUser.setRoles(['global_devtools_read', 'ingest_pipelines_user']); | ||
await PageObjects.common.navigateToApp('grokDebugger'); | ||
await retry.waitFor('Grok Debugger Header to be visible', async () => { | ||
return testSubjects.isDisplayed('grokDebuggerContainer'); | ||
}); | ||
}); | ||
|
||
it('Loads the app', async () => { | ||
await retry.waitForWithTimeout('Grok Debugger to be visible', 15000, async () => { | ||
return await (await PageObjects.grokDebugger.simulateButton()).isDisplayed(); | ||
}); | ||
}); | ||
|
||
it('Accept and parse input with built-in grok pattern', async () => { | ||
const eventInput = 'SegerCommaBob'; | ||
const patternInput = '%{USERNAME:u}'; | ||
const response = await PageObjects.grokDebugger.executeGrokSimulation( | ||
eventInput, | ||
patternInput, | ||
null | ||
); | ||
expect(response).to.eql({ u: 'SegerCommaBob' }); | ||
}); | ||
|
||
it('Accept and parse input with custom grok pattern', async () => { | ||
await PageObjects.common.navigateToApp('grokDebugger'); | ||
const eventInput = | ||
'Jan 1 06:25:43 mailserver14 postfix/cleanup[21403]: BEF25A72965: message-id=<[email protected]>'; | ||
const patternInput = '%{SYSLOGBASE} %{POSTFIX_QUEUEID:queue_id}: %{MSG:syslog_message}'; | ||
const customPatternInput = 'POSTFIX_QUEUEID [0-9A-F]{10,11}\nMSG message-id=<%{GREEDYDATA}>'; | ||
const testData = { | ||
pid: '21403', | ||
program: 'postfix/cleanup', | ||
logsource: 'mailserver14', | ||
syslog_message: 'message-id=<[email protected]>', | ||
queue_id: 'BEF25A72965', | ||
timestamp: 'Jan 1 06:25:43', | ||
}; | ||
|
||
const response = await PageObjects.grokDebugger.executeGrokSimulation( | ||
eventInput, | ||
patternInput, | ||
customPatternInput | ||
); | ||
expect(response).to.eql(testData); | ||
}); | ||
|
||
// This test will need to be fixed. | ||
it.skip('applies the correct CSS classes', async () => { | ||
const grokPattern = '\\[(?:-|%{NUMBER:bytes:int})\\]'; | ||
|
||
await PageObjects.grokDebugger.setPatternInput(grokPattern); | ||
|
||
const GROK_START = 'grokStart'; | ||
const GROK_PATTERN_NAME = 'grokPatternName'; | ||
const GROK_SEPARATOR = 'grokSeparator'; | ||
const GROK_FIELD_NAME = 'grokFieldName'; | ||
const GROK_FIELD_TYPE = 'grokFieldType'; | ||
const GROK_END = 'grokEnd'; | ||
const GROK_ESCAPE = 'grokEscape'; | ||
const GROK_ESCAPED = 'grokEscaped'; | ||
const GROK_REGEX = 'grokRegex'; | ||
|
||
await PageObjects.grokDebugger.assertPatternInputSyntaxHighlighting([ | ||
{ token: GROK_ESCAPE, content: '\\' }, | ||
{ token: GROK_ESCAPED, content: '[' }, | ||
{ token: GROK_REGEX, content: '(' }, | ||
{ token: GROK_REGEX, content: '?' }, | ||
{ token: GROK_REGEX, content: ':' }, | ||
{ token: GROK_REGEX, content: '|' }, | ||
{ token: GROK_START, content: '%{' }, | ||
{ token: GROK_PATTERN_NAME, content: 'NUMBER' }, | ||
{ token: GROK_SEPARATOR, content: ':' }, | ||
{ token: GROK_FIELD_NAME, content: 'bytes' }, | ||
{ token: GROK_SEPARATOR, content: ':' }, | ||
{ token: GROK_FIELD_TYPE, content: 'int' }, | ||
{ token: GROK_END, content: '}' }, | ||
{ token: GROK_REGEX, content: ')' }, | ||
{ token: GROK_ESCAPE, content: '\\' }, | ||
{ token: GROK_ESCAPED, content: ']' }, | ||
]); | ||
}); | ||
|
||
after(async () => { | ||
await security.testUser.restoreDefaults(); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters