Skip to content

Commit d1e4fe8

Browse files
committed
Fix SingleNodeTests
Closes elastic#36782
1 parent bda5914 commit d1e4fe8

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ protected void assertWatchWithMinimumActionsCount(final String watchName, final
433433
});
434434
}
435435

436-
private void ensureWatcherTemplatesAdded() throws Exception {
436+
protected void ensureWatcherTemplatesAdded() throws Exception {
437437
// Verify that the index templates exist:
438438
assertBusy(() -> {
439439
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get();

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SingleNodeTests.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
*/
66
package org.elasticsearch.xpack.watcher.test.integration;
77

8-
import org.apache.lucene.util.LuceneTestCase;
9-
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
108
import org.elasticsearch.action.search.SearchResponse;
11-
import org.elasticsearch.cluster.metadata.IndexMetaData;
129
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
1310
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
1411
import org.elasticsearch.xpack.core.watcher.watch.Watch;
1512
import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
1613
import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
17-
import org.elasticsearch.xpack.watcher.watch.WatchStoreUtils;
18-
19-
import java.util.concurrent.TimeUnit;
2014

2115
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
22-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
2316
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.loggingAction;
2417
import static org.elasticsearch.xpack.watcher.client.WatchSourceBuilders.watchBuilder;
2518
import static org.elasticsearch.xpack.watcher.input.InputBuilders.simpleInput;
@@ -28,8 +21,7 @@
2821
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
2922
import static org.hamcrest.Matchers.is;
3023

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)
3325
public class SingleNodeTests extends AbstractWatcherIntegrationTestCase {
3426

3527
@Override
@@ -41,28 +33,29 @@ protected boolean timeWarped() {
4133
// the index does not exist, a watch gets added
4234
// the watch should be executed properly, despite the index being created and the cluster state listener being reloaded
4335
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());
4941
startWatcher();
5042

5143
String watchId = randomAlphaOfLength(20);
5244
// now we start with an empty set up, store a watch and expected it to be executed
5345
PutWatchResponse putWatchResponse = watcherClient().preparePutWatch(watchId)
5446
.setSource(watchBuilder()
55-
.trigger(schedule(interval(1, IntervalSchedule.Interval.Unit.SECONDS)))
47+
.trigger(schedule(interval(1, IntervalSchedule.Interval.Unit.DAYS)))
5648
.input(simpleInput())
5749
.addAction("_logger", loggingAction("logging of watch _name")))
5850
.get();
5951
assertThat(putWatchResponse.isCreated(), is(true));
6052

6153
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+
});
6659
}
6760

6861
}

0 commit comments

Comments
 (0)