5
5
*/
6
6
package org .elasticsearch .xpack .watcher .test .integration ;
7
7
8
- import org .apache .lucene .util .LuceneTestCase ;
9
- import org .elasticsearch .action .admin .cluster .state .ClusterStateResponse ;
10
8
import org .elasticsearch .action .search .SearchResponse ;
11
- import org .elasticsearch .cluster .metadata .IndexMetaData ;
12
9
import org .elasticsearch .protocol .xpack .watcher .PutWatchResponse ;
13
10
import org .elasticsearch .test .ESIntegTestCase .ClusterScope ;
14
11
import org .elasticsearch .xpack .core .watcher .watch .Watch ;
15
12
import org .elasticsearch .xpack .watcher .test .AbstractWatcherIntegrationTestCase ;
16
13
import org .elasticsearch .xpack .watcher .trigger .schedule .IntervalSchedule ;
17
- import org .elasticsearch .xpack .watcher .watch .WatchStoreUtils ;
18
-
19
- import java .util .concurrent .TimeUnit ;
20
14
21
15
import static org .elasticsearch .test .ESIntegTestCase .Scope .SUITE ;
22
- import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
23
16
import static org .elasticsearch .xpack .watcher .actions .ActionBuilders .loggingAction ;
24
17
import static org .elasticsearch .xpack .watcher .client .WatchSourceBuilders .watchBuilder ;
25
18
import static org .elasticsearch .xpack .watcher .input .InputBuilders .simpleInput ;
28
21
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
29
22
import static org .hamcrest .Matchers .is ;
30
23
31
- @ LuceneTestCase .AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/36782" )
32
- @ ClusterScope (scope = SUITE , numClientNodes = 0 , transportClientRatio = 0 , maxNumDataNodes = 1 , supportsDedicatedMasters = false )
24
+ @ ClusterScope (scope = SUITE , numClientNodes = 0 , transportClientRatio = 0 , numDataNodes = 0 , supportsDedicatedMasters = false )
33
25
public class SingleNodeTests extends AbstractWatcherIntegrationTestCase {
34
26
35
27
@ Override
@@ -41,28 +33,29 @@ protected boolean timeWarped() {
41
33
// the index does not exist, a watch gets added
42
34
// the watch should be executed properly, despite the index being created and the cluster state listener being reloaded
43
35
public void testThatLoadingWithNonExistingIndexWorks () throws Exception {
44
- stopWatcher ();
45
- ClusterStateResponse clusterStateResponse = client (). admin (). cluster (). prepareState (). get ();
46
- IndexMetaData metaData = WatchStoreUtils . getConcreteIndex ( Watch . INDEX , clusterStateResponse . getState (). metaData () );
47
- String watchIndexName = metaData . getIndex (). getName ();
48
- assertAcked (client ().admin ().indices ().prepareDelete ( watchIndexName ));
36
+ internalCluster (). startNode ();
37
+ ensureLicenseEnabled ();
38
+ ensureWatcherTemplatesAdded ( );
39
+
40
+ assertFalse (client ().admin ().indices ().prepareExists ( Watch . INDEX ). get (). isExists ( ));
49
41
startWatcher ();
50
42
51
43
String watchId = randomAlphaOfLength (20 );
52
44
// now we start with an empty set up, store a watch and expected it to be executed
53
45
PutWatchResponse putWatchResponse = watcherClient ().preparePutWatch (watchId )
54
46
.setSource (watchBuilder ()
55
- .trigger (schedule (interval (1 , IntervalSchedule .Interval .Unit .SECONDS )))
47
+ .trigger (schedule (interval (1 , IntervalSchedule .Interval .Unit .DAYS )))
56
48
.input (simpleInput ())
57
49
.addAction ("_logger" , loggingAction ("logging of watch _name" )))
58
50
.get ();
59
51
assertThat (putWatchResponse .isCreated (), is (true ));
60
52
61
53
assertBusy (() -> {
62
- client ().admin ().indices ().prepareRefresh (".watcher-history*" );
63
- SearchResponse searchResponse = client ().prepareSearch (".watcher-history*" ).setSize (0 ).get ();
64
- assertThat (searchResponse .getHits ().getTotalHits ().value , is (greaterThanOrEqualTo (1L )));
65
- }, 5 , TimeUnit .SECONDS );
54
+ watcherClient ().prepareExecuteWatch (watchId ).setRecordExecution (true ).get ();
55
+ refresh (".watcher-history*" );
56
+ final SearchResponse searchResponse = client ().prepareSearch (".watcher-history*" ).setSize (0 ).get ();
57
+ assertThat (searchResponse .getHits ().getTotalHits ().value , greaterThanOrEqualTo (1L ));
58
+ });
66
59
}
67
60
68
61
}
0 commit comments