Skip to content

Commit 53b5ee3

Browse files
authored
Merge pull request #1374 from untergeek/fix/merge_test
Fix CI test timing issue
2 parents 7a95468 + 072c0d6 commit 53b5ee3

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

test/integration/test_forcemerge.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import curator
33
import os
44
import json
5-
import string, random, tempfile
5+
import string
6+
import random
7+
import tempfile
8+
from time import sleep
69
import click
710
from click import testing as clicktest
811
from mock import patch, Mock
@@ -34,9 +37,18 @@ def test_merge(self):
3437
curator.cli,
3538
['--config', self.args['configfile'], self.args['actionfile']],
3639
)
37-
self.client.indices.refresh(index=idx)
3840
ilo2 = curator.IndexList(self.client)
39-
ilo2._get_segment_counts()
41+
# This stupid block is only for the benefit of Travis CI
42+
# With Python 2.7 and ES 7.0, it apparently can finish testing before
43+
# the segments have _reported_ as fully merged. This is forcing
44+
# 3 checks before giving up and reporting the result.
45+
for _ in range(0, 3):
46+
self.client.indices.refresh(index=idx)
47+
ilo2._get_segment_counts()
48+
if ilo2.index_info[idx]['segments'] == count:
49+
break
50+
else:
51+
sleep(1)
4052
self.assertEqual(count, ilo2.index_info[idx]['segments'])
4153
def test_extra_option(self):
4254
self.write_config(
@@ -67,10 +79,20 @@ def test_merge(self):
6779
'--config', self.args['configfile'],
6880
'forcemerge',
6981
'--max_num_segments', str(count),
70-
'--delay', '0.20',
82+
'--delay', '0.9',
7183
'--filter_list', '{"filtertype":"pattern","kind":"prefix","value":"my"}',
7284
]
7385
self.assertEqual(0, self.run_subprocess(args, logname='TestCLIforceMerge.test_merge'))
7486
ilo2 = curator.IndexList(self.client)
75-
ilo2._get_segment_counts()
87+
# This stupid block is only for the benefit of Travis CI
88+
# With Python 2.7 and ES 7.0, it apparently can finish testing before
89+
# the segments have _reported_ as fully merged. This is forcing
90+
# 3 checks before giving up and reporting the result.
91+
for _ in range(0, 3):
92+
self.client.indices.refresh(index=idx)
93+
ilo2._get_segment_counts()
94+
if ilo2.index_info[idx]['segments'] == count:
95+
break
96+
else:
97+
sleep(1)
7698
self.assertEqual(count, ilo2.index_info[idx]['segments'])

0 commit comments

Comments
 (0)