Skip to content

Commit

Permalink
Use unique event log for Winlogbeat system tests (elastic#8006)
Browse files Browse the repository at this point in the history
This changes the Winlogbeat system tests to use a unique event log for each test case.
The event log name and the registered source applications will each be suffixed with
a short hash created from the Windows API name (eventlogging or wineventlog) and the
python test name.

This should help isolate the test cases from one another.

Fixes elastic#7902

(cherry picked from commit 4da32c4)
  • Loading branch information
andrewkroh committed Aug 21, 2018
1 parent 03ac3c9 commit 088a470
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions winlogbeat/tests/system/winlogbeat.py
@@ -1,3 +1,4 @@
import hashlib
import os
import platform
import sys
Expand All @@ -14,6 +15,10 @@

from beat.beat import TestCase

PROVIDER = "WinlogbeatTestPython"
APP_NAME = "SystemTest"
OTHER_APP_NAME = "OtherSystemTestApp"


class BaseTest(TestCase):

Expand All @@ -25,15 +30,24 @@ def setUpClass(self):


class WriteReadTest(BaseTest):
providerName = "WinlogbeatTestPython"
applicationName = "SystemTest"
otherAppName = "OtherSystemTestApp"
providerName = PROVIDER
applicationName = APP_NAME
otherAppName = OTHER_APP_NAME
testSuffix = None
sid = None
sidString = None
api = None

def setUp(self):
super(WriteReadTest, self).setUp()

# Every test will use its own event log and application names to ensure
# isolation.
self.testSuffix = "_" + hashlib.sha256(self.api + self._testMethodName).hexdigest()[:5]
self.providerName = PROVIDER + self.testSuffix
self.applicationName = APP_NAME + self.testSuffix
self.otherAppName = OTHER_APP_NAME + self.testSuffix

win32evtlogutil.AddSourceToRegistry(self.applicationName,
"%systemroot%\\system32\\EventCreate.exe",
self.providerName)
Expand Down

0 comments on commit 088a470

Please sign in to comment.