Skip to content

Commit

Permalink
Fixes in place
Browse files Browse the repository at this point in the history
  • Loading branch information
untergeek committed Jan 31, 2023
1 parent e5dbe91 commit edd3b32
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cover
coverage.xml
dist
docker_test/repo/
docker_test/scripts/Dockerfile
docs/_build
docs/asciidoc/html_docs
elasticsearch_curator.egg-info
Expand Down
88 changes: 44 additions & 44 deletions test/integration/test_reindex.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import curator
import os
import json
import string
import random
import tempfile
import click
import pytest
from click import testing as clicktest
import time
import curator

from . import CuratorTestCase
from unittest.case import SkipTest
from . import testvars as testvars

import logging
logger = logging.getLogger(__name__)
from . import testvars

UNDEF = 'undefined'
host, port = os.environ.get('TEST_ES_SERVER', 'localhost:9200').split(':')
rhost, rport = os.environ.get('REMOTE_ES_SERVER', 'localhost:9201').split(':')
RHOST, RPORT = os.environ.get('REMOTE_ES_SERVER', f'{UNDEF}:9201').split(':')
port = int(port) if port else 9200
rport = int(rport) if rport else 9201
RPORT = int(RPORT) if RPORT else 9201

class TestActionFileReindex(CuratorTestCase):
def test_reindex_manual(self):
Expand Down Expand Up @@ -170,6 +163,8 @@ def test_reindex_selected_empty_list_pass(self):
['--config', self.args['configfile'], self.args['actionfile']],
)
self.assertEqual(_.exit_code, 0)

@pytest.mark.skipif((RHOST == UNDEF), reason='REMOTE_ES_SERVER is not defined')
def test_reindex_from_remote(self):
wait_interval = 1
max_wait = 3
Expand All @@ -182,11 +177,11 @@ def test_reindex_from_remote(self):
# Build remote client
try:
rclient = curator.get_client(
host=rhost, port=rport, skip_version_test=True)
host=RHOST, port=RPORT, skip_version_test=True)
rclient.info()
except:
raise SkipTest(
'Unable to connect to host at {0}:{1}'.format(rhost, rport))
'Unable to connect to host at {0}:{1}'.format(RHOST, RPORT))
# Build indices remotely.
counter = 0
for rindex in [source1, source2]:
Expand All @@ -204,10 +199,10 @@ def test_reindex_from_remote(self):
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.remote_reindex.format(
wait_interval,
max_wait,
'http://{0}:{1}'.format(rhost, rport),
'REINDEX_SELECTION',
wait_interval,
max_wait,
'http://{0}:{1}'.format(RHOST, RPORT),
'REINDEX_SELECTION',
dest,
prefix
)
Expand All @@ -220,6 +215,8 @@ def test_reindex_from_remote(self):
# Do our own cleanup here.
rclient.indices.delete(index='{0},{1}'.format(source1, source2))
self.assertEqual(expected, self.client.count(index=dest)['count'])

@pytest.mark.skipif((RHOST == UNDEF), reason='REMOTE_ES_SERVER is not defined')
def test_reindex_migrate_from_remote(self):
wait_interval = 1
max_wait = 3
Expand All @@ -233,11 +230,11 @@ def test_reindex_migrate_from_remote(self):
# Build remote client
try:
rclient = curator.get_client(
host=rhost, port=rport, skip_version_test=True)
host=RHOST, port=RPORT, skip_version_test=True)
rclient.info()
except:
raise SkipTest(
'Unable to connect to host at {0}:{1}'.format(rhost, rport))
'Unable to connect to host at {0}:{1}'.format(RHOST, RPORT))
# Build indices remotely.
counter = 0
for rindex in [source1, source2]:
Expand All @@ -255,10 +252,10 @@ def test_reindex_migrate_from_remote(self):
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.remote_reindex.format(
wait_interval,
max_wait,
'http://{0}:{1}'.format(rhost, rport),
'REINDEX_SELECTION',
wait_interval,
max_wait,
'http://{0}:{1}'.format(RHOST, RPORT),
'REINDEX_SELECTION',
dest,
prefix
)
Expand All @@ -270,11 +267,12 @@ def test_reindex_migrate_from_remote(self):
)
# Do our own cleanup here.
rclient.indices.delete(index='{0},{1}'.format(source1, source2))
# And now the neat trick of verifying that the reindex worked to both
# And now the neat trick of verifying that the reindex worked to both
# indices, and they preserved their names
self.assertEqual(expected, self.client.count(index=source1)['count'])
self.assertEqual(expected, self.client.count(index=source2)['count'])

@pytest.mark.skipif((RHOST == UNDEF), reason='REMOTE_ES_SERVER is not defined')
def test_reindex_migrate_from_remote_with_pre_suf_fixes(self):
wait_interval = 1
max_wait = 3
Expand All @@ -290,11 +288,11 @@ def test_reindex_migrate_from_remote_with_pre_suf_fixes(self):
# Build remote client
try:
rclient = curator.get_client(
host=rhost, port=rport, skip_version_test=True)
host=RHOST, port=RPORT, skip_version_test=True)
rclient.info()
except:
raise SkipTest(
'Unable to connect to host at {0}:{1}'.format(rhost, rport))
'Unable to connect to host at {0}:{1}'.format(RHOST, RPORT))
# Build indices remotely.
counter = 0
for rindex in [source1, source2]:
Expand All @@ -312,12 +310,12 @@ def test_reindex_migrate_from_remote_with_pre_suf_fixes(self):
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.migration_reindex.format(
wait_interval,
wait_interval,
max_wait,
mpfx,
msfx,
'http://{0}:{1}'.format(rhost, rport),
'REINDEX_SELECTION',
'http://{0}:{1}'.format(RHOST, RPORT),
'REINDEX_SELECTION',
dest,
prefix
)
Expand All @@ -329,7 +327,7 @@ def test_reindex_migrate_from_remote_with_pre_suf_fixes(self):
)
# Do our own cleanup here.
rclient.indices.delete(index='{0},{1}'.format(source1, source2))
# And now the neat trick of verifying that the reindex worked to both
# And now the neat trick of verifying that the reindex worked to both
# indices, and they preserved their names
self.assertEqual(expected, self.client.count(index='{0}{1}{2}'.format(mpfx,source1,msfx))['count'])
self.assertEqual(expected, self.client.count(index='{0}{1}{2}'.format(mpfx,source1,msfx))['count'])
Expand All @@ -344,10 +342,10 @@ def test_reindex_from_remote_no_connection(self):
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.remote_reindex.format(
wait_interval,
max_wait,
'http://{0}:{1}'.format(rhost, bad_port),
'REINDEX_SELECTION',
wait_interval,
max_wait,
'http://{0}:{1}'.format(RHOST, bad_port),
'REINDEX_SELECTION',
dest,
'my_'
)
Expand All @@ -358,6 +356,8 @@ def test_reindex_from_remote_no_connection(self):
['--config', self.args['configfile'], self.args['actionfile']],
)
self.assertEqual(expected, _.exit_code)

@pytest.mark.skipif((RHOST == UNDEF), reason='REMOTE_ES_SERVER is not defined')
def test_reindex_from_remote_no_indices(self):
wait_interval = 1
max_wait = 3
Expand All @@ -370,11 +370,11 @@ def test_reindex_from_remote_no_indices(self):
# Build remote client
try:
rclient = curator.get_client(
host=rhost, port=rport, skip_version_test=True)
host=RHOST, port=RPORT, skip_version_test=True)
rclient.info()
except:
raise SkipTest(
'Unable to connect to host at {0}:{1}'.format(rhost, rport))
'Unable to connect to host at {0}:{1}'.format(RHOST, RPORT))
# Build indices remotely.
counter = 0
for rindex in [source1, source2]:
Expand All @@ -387,15 +387,15 @@ def test_reindex_from_remote_no_indices(self):
counter += 1
# Decorators make this pylint exception necessary
# pylint: disable=E1123
rclient.indices.flush(index=rindex, force=True)
rclient.indices.flush(index=rindex, force=True)
self.write_config(
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'],
testvars.remote_reindex.format(
wait_interval,
max_wait,
'http://{0}:{1}'.format(rhost, rport),
'REINDEX_SELECTION',
wait_interval,
max_wait,
'http://{0}:{1}'.format(RHOST, RPORT),
'REINDEX_SELECTION',
dest,
prefix
)
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_reindex_manual_date_math(self):
)
self.assertEqual(expected, self.client.count(index=dest)['count'])
def test_reindex_bad_mapping(self):
# This test addresses GitHub issue #1260
# This test addresses GitHub issue #1260
wait_interval = 1
max_wait = 3
source = 'my_source'
Expand Down

0 comments on commit edd3b32

Please sign in to comment.