<s> import elasticsearch <EOL> import curator <EOL> import os <EOL> import json <EOL> import string , random , tempfile <EOL> import click <EOL> from click import testing as clicktest <EOL> from mock import patch , Mock <EOL> from . import CuratorTestCase <EOL> from . import testvars as testvars <EOL> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> host , port = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) . split ( '<STR_LIT::>' ) <EOL> port = int ( port ) if port else <NUM_LIT> <EOL> class TestCLIforceMerge ( CuratorTestCase ) : <EOL> def test_merge ( self ) : <EOL> count = <NUM_LIT:1> <EOL> idx = '<STR_LIT>' <EOL> self . create_index ( idx ) <EOL> for i in [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" ] : <EOL> self . client . create ( <EOL> index = idx , doc_type = '<STR_LIT>' , <EOL> body = { "<STR_LIT>" + i : '<STR_LIT>' } , <EOL> ) <EOL> self . client . indices . flush ( index = idx , force = True ) <EOL> ilo1 = curator . IndexList ( self . client ) <EOL> ilo1 . _get_segmentcounts ( ) <EOL> self . assertEqual ( <NUM_LIT:3> , ilo1 . index_info [ idx ] [ '<STR_LIT>' ] ) <EOL> self . write_config ( <EOL> self . args [ '<STR_LIT>' ] , testvars . client_config . format ( host , port ) ) <EOL> self . write_config ( self . args [ '<STR_LIT>' ] , <EOL> testvars . forcemerge_test . format ( count , <NUM_LIT> ) ) <EOL> test = clicktest . CliRunner ( ) <EOL> result = test . invoke ( <EOL> curator . cli , <EOL> [ <EOL> '<STR_LIT>' , self . args [ '<STR_LIT>' ] , <EOL> self . args [ '<STR_LIT>' ] <EOL> ] , <EOL> ) <EOL> ilo2 = curator . IndexList ( self . client ) <EOL> ilo2 . _get_segmentcounts ( ) <EOL> self . assertEqual ( count , ilo2 . index_info [ idx ] [ '<STR_LIT>' ] ) <EOL> def test_no_max_num_segments ( self ) : <EOL> self . write_config ( <EOL> self . args [ '<STR_LIT>' ] , testvars . client_config . format ( host , port ) ) <EOL> self . write_config ( self . args [ '<STR_LIT>' ] , <EOL> testvars . forcemerge_test . format ( '<STR_LIT:U+0020>' , <NUM_LIT:0> ) ) <EOL> test = clicktest . CliRunner ( ) <EOL> result = test . invoke ( <EOL> curator . cli , <EOL> [ <EOL> '<STR_LIT>' , self . args [ '<STR_LIT>' ] , <EOL> self . args [ '<STR_LIT>' ] <EOL> ] , <EOL> ) <EOL> self . assertEqual ( <NUM_LIT:1> , result . exit_code ) <EOL> def test_extra_option ( self ) : <EOL> self . write_config ( <EOL> self . args [ '<STR_LIT>' ] , testvars . client_config . format ( host , port ) ) <EOL> self . write_config ( self . args [ '<STR_LIT>' ] , <EOL> testvars . bad_option_proto_test . format ( '<STR_LIT>' ) ) <EOL> test = clicktest . CliRunner ( ) <EOL> result = test . invoke ( <EOL> curator . cli , <EOL> [ <EOL> '<STR_LIT>' , self . args [ '<STR_LIT>' ] , <EOL> self . args [ '<STR_LIT>' ] <EOL> ] , <EOL> ) <EOL> self . assertEqual ( <NUM_LIT:1> , result . exit_code ) </s>
