Add if statement to other areas of delete_index

This commit is contained in:
Brandon Myers 2017-06-01 14:10:03 -05:00
Родитель 302eb1b665
Коммит d8c742701d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8AA79AD83045BBC7
2 изменённых файлов: 61 добавлений и 29 удалений

Просмотреть файл

@ -1,3 +1,14 @@
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
#
# Contributors:
# Brandon Myers bmyers@mozilla.com
import os
import sys
@ -272,10 +283,12 @@ class TestGetIndices(ElasticsearchClientTest):
def teardown(self):
super(TestGetIndices, self).teardown()
self.es_client.delete_index('test_index')
if pytest.config.option.delete_indexes:
self.es_client.delete_index('test_index')
def test_get_indices(self):
self.es_client.create_index('test_index')
if pytest.config.option.delete_indexes:
self.es_client.create_index('test_index')
time.sleep(0.5)
indices = self.es_client.get_indices()
indices.sort()
@ -305,29 +318,33 @@ class TestCreatingAlias(ElasticsearchClientTest):
def setup(self):
super(TestCreatingAlias, self).setup()
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
self.es_client.delete_index('alias1', True)
if pytest.config.option.delete_indexes:
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
self.es_client.delete_index('alias1', True)
def teardown(self):
super(TestCreatingAlias, self).teardown()
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
self.es_client.delete_index('alias1', True)
if pytest.config.option.delete_indexes:
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
self.es_client.delete_index('alias1', True)
def test_simple_create_alias(self):
self.es_client.create_index('index1')
self.es_client.create_alias('alias1', 'index1')
if pytest.config.option.delete_indexes:
self.es_client.create_index('index1')
self.es_client.create_alias('alias1', 'index1')
alias_indices = self.es_client.get_alias('alias1')
assert alias_indices == ['index1']
indices = self.es_client.get_indices()
assert 'index1' in indices
def test_alias_multiple_indices(self):
self.es_client.create_index('index1')
self.es_client.create_index('index2')
self.es_client.create_alias('alias1', 'index1')
self.es_client.create_alias('alias1', 'index2')
if pytest.config.option.delete_indexes:
self.es_client.create_index('index1')
self.es_client.create_index('index2')
self.es_client.create_alias('alias1', 'index1')
self.es_client.create_alias('alias1', 'index2')
alias_indices = self.es_client.get_alias('alias1')
assert alias_indices == ['index2']
indices = self.es_client.get_indices()
@ -367,11 +384,12 @@ class TestBulkInvalidFormatProblem(BulkTest):
# Recreate the test indexes with a custom mapping to throw
# parsing errors
self.es_client.delete_index("events", True)
self.es_client.delete_index(self.event_index_name, True)
self.es_client.create_index(self.event_index_name, mapping=mapping)
self.es_client.create_alias('events', self.event_index_name)
self.es_client.create_alias('events-previous', self.event_index_name)
if pytest.config.option.delete_indexes:
self.es_client.delete_index("events", True)
self.es_client.delete_index(self.event_index_name, True)
self.es_client.create_index(self.event_index_name, mapping=mapping)
self.es_client.create_alias('events', self.event_index_name)
self.es_client.create_alias('events-previous', self.event_index_name)
def test_bulk_problems(self):
event = {

Просмотреть файл

@ -1,7 +1,19 @@
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
#
# Contributors:
# Brandon Myers bmyers@mozilla.com
import os
import json
import time
import pytest
from dateutil.parser import parse
from rest_test_suite import RestTestSuite
@ -28,13 +40,15 @@ class TestKibanaDashboardsRoute(RestTestSuite):
def teardown(self):
super(TestKibanaDashboardsRoute, self).teardown()
self.es_client.delete_index('.kibana', True)
if pytest.config.option.delete_indexes:
self.es_client.delete_index('.kibana', True)
def setup(self):
super(TestKibanaDashboardsRoute, self).setup()
if pytest.config.option.delete_indexes:
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
json_dashboard_location = os.path.join(os.path.dirname(__file__), "ssh_dashboard.json")
self.es_client.save_dashboard(json_dashboard_location, "Example SSH Dashboard")
self.es_client.save_dashboard(json_dashboard_location, "Example FTP Dashboard")
@ -52,12 +66,10 @@ class TestKibanaDashboardsRoute(RestTestSuite):
json_resp.sort()
assert json_resp[1]['url'].endswith(
":9090/index.html#/dashboard/elasticsearch/Example SSH Dashboard") is True
assert json_resp[1]['url'].endswith(":9090/index.html#/dashboard/elasticsearch/Example SSH Dashboard") is True
assert json_resp[1]['name'] == 'Example SSH Dashboard'
assert json_resp[0]['url'].endswith(
":9090/index.html#/dashboard/elasticsearch/Example FTP Dashboard") is True
assert json_resp[0]['url'].endswith(":9090/index.html#/dashboard/elasticsearch/Example FTP Dashboard") is True
assert json_resp[0]['name'] == 'Example FTP Dashboard'
@ -68,13 +80,15 @@ class TestKibanaDashboardsRouteWithoutDashboards(RestTestSuite):
def setup(self):
super(TestKibanaDashboardsRouteWithoutDashboards, self).setup()
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
if pytest.config.option.delete_indexes:
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
time.sleep(0.2)
def teardown(self):
super(TestKibanaDashboardsRouteWithoutDashboards, self).teardown()
self.es_client.delete_index('.kibana', True)
if pytest.config.option.delete_indexes:
self.es_client.delete_index('.kibana', True)
def test_route_endpoints(self):
for route in self.routes: