test: fix failing tests

Original commit: elastic/x-pack-elasticsearch@3c35a828a4
This commit is contained in:
Martijn van Groningen 2015-05-02 02:22:37 +02:00
parent 31f039d1bd
commit 3b652d1772
2 changed files with 15 additions and 11 deletions

View File

@ -194,15 +194,9 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests {
stopWatcher();
startWatcher();
assertBusy(new Runnable() {
@Override
public void run() {
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatchServiceState(), equalTo(WatcherService.State.STARTED));
assertThat(response.getWatchesCount(), equalTo(1l));
assertThat(response.getWatchExecutionQueueMaxSize(), equalTo(1l));
}
});
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatchServiceState(), equalTo(WatcherService.State.STARTED));
assertThat(response.getWatchesCount(), equalTo(1l));
}
@Test

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.watcher.watch;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
import org.elasticsearch.action.search.ClearScrollResponse;
@ -26,6 +27,7 @@ import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.elasticsearch.watcher.WatcherException;
import org.elasticsearch.watcher.support.TemplateUtils;
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
import org.junit.Before;
@ -124,7 +126,11 @@ public class WatchStoreTests extends ElasticsearchTestCase {
ClusterState cs = csBuilder.build();
assertThat(watchStore.validate(cs), is(true));
watchStore.start(cs);
try {
watchStore.start(cs);
} catch (WatcherException e) {
assertThat(e.getMessage(), equalTo("not all required shards have been refreshed"));
}
verifyZeroInteractions(templateUtils);
verify(clientProxy, times(1)).refresh(any(RefreshRequest.class));
verify(clientProxy, never()).search(any(SearchRequest.class));
@ -160,7 +166,11 @@ public class WatchStoreTests extends ElasticsearchTestCase {
ClusterState cs = csBuilder.build();
assertThat(watchStore.validate(cs), is(true));
watchStore.start(cs);
try {
watchStore.start(cs);
} catch (ElasticsearchException e) {
assertThat(e.getMessage(), equalTo("Partial response while loading watches"));
}
verifyZeroInteractions(templateUtils);
verify(clientProxy, times(1)).refresh(any(RefreshRequest.class));
verify(clientProxy, times(1)).search(any(SearchRequest.class));