Skip to content

Commit

Permalink
Event index is not available on integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Jan 18, 2022
1 parent ecc2676 commit 1d70a33
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions x-pack/metricbeat/module/enterprisesearch/test_enterprisesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ class Test(XPackTest):

# -------------------------------------------------------------------------
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, 'integration test')
def test_health_xpack_disabled(self, xpackEnabled):
"""Tests the Health API and the associated metricset with XPack disabled"""
self.health_check(xpackEnabled=False)

@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, 'integration test')
def test_health_xpack_enabled(self, xpackEnabled):
"""Tests the Health API and the associated metricset with XPack enabled"""
self.health_check(xpackEnabled=True)

def health_check(self, xpackEnabled):
def test_health(self):
"""Tests the Health API and the associated metricset"""

# Setup the environment
self.setup_environment(metricset="health", xpackEnabled=xpackEnabled)
self.setup_environment(metricset="health")

# Get a single event for testing
evt = self.get_event()
Expand All @@ -33,23 +25,14 @@ def health_check(self, xpackEnabled):

health = evt["enterprisesearch"]["health"]
self.assertIn("jvm", health)
self.assertEqual(evt["index"].startsWith(".monitoring-"), xpackEnabled)

# -------------------------------------------------------------------------
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, 'integration test')
def test_stats_xpack_disabled(self):
"""Tests the Stats API and the associated metricset with XPack disabled"""
self.stats_check(xpackEnabled=False)

@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, 'integration test')
def test_stats_xpack_enabled(self):
"""Tests the Stats API and the associated metricset with XPack enabled"""
self.stats_check(xpackEnabled=True)

def stats_check(self, xpackEnabled):
def test_stats(self):
"""Tests the Stats API and the associated metricset"""

# Setup the environment
self.setup_environment(metricset="stats", xpackEnabled=xpackEnabled)
self.setup_environment(metricset="stats")

# Get a single event for testing
evt = self.get_event()
Expand All @@ -59,10 +42,9 @@ def stats_check(self, xpackEnabled):

stats = evt["enterprisesearch"]["stats"]
self.assertIn("http", stats)
self.assertEqual(evt["index"].startsWith(".monitoring-"), xpackEnabled)

# -------------------------------------------------------------------------
def setup_environment(self, metricset, xpackEnabled):
def setup_environment(self, metricset):
"""Sets up the testing environment and starts all components needed"""

self.render_config_template(modules=[{
Expand All @@ -71,8 +53,7 @@ def setup_environment(self, metricset, xpackEnabled):
"hosts": [self.compose_host(service="enterprise_search")],
"username": self.get_username(),
"password": self.get_password(),
"period": "5s",
"xpack.enabled": xpackEnabled
"period": "5s"
}])

proc = self.start_beat(home=self.beat_path)
Expand Down

0 comments on commit 1d70a33

Please sign in to comment.