more test fixes - more nocommits

Original commit: elastic/x-pack-elasticsearch@9d230d3b71
This commit is contained in:
Simon Willnauer 2015-06-16 10:08:24 +02:00
parent d3bd643bf4
commit 491e8fc167
9 changed files with 22 additions and 26 deletions

View File

@ -79,14 +79,15 @@ public class InternalEmailService extends AbstractLifecycleComponent<InternalEma
void reset(Settings nodeSettings) { void reset(Settings nodeSettings) {
Settings.Builder builder = Settings.builder(); Settings.Builder builder = Settings.builder();
String prefix = "watcher.actions.email.service";
for (String setting : settings.getAsMap().keySet()) { for (String setting : settings.getAsMap().keySet()) {
if (setting.startsWith("watcher.actions.email.service")) { if (setting.startsWith("watcher.actions.email.service")) {
builder.put(setting, settings.get(setting)); builder.put(setting.substring(prefix.length()+1), settings.get(setting));
} }
} }
for (String setting : nodeSettings.getAsMap().keySet()) { for (String setting : nodeSettings.getAsMap().keySet()) {
if (setting.startsWith("watcher.actions.email.service")) { if (setting.startsWith("watcher.actions.email.service")) {
builder.put(setting, settings.get(setting)); builder.put(setting.substring(prefix.length()+1), settings.get(setting));
} }
} }
accounts = createAccounts(builder.build(), logger); accounts = createAccounts(builder.build(), logger);

View File

@ -13,6 +13,7 @@ import org.elasticsearch.common.compress.Compressor;
import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.compress.CompressorFactory;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
@ -30,18 +31,8 @@ public class WatcherXContentUtils {
public static Tuple<XContentType, Object> convertToObject(BytesReference bytes) throws ElasticsearchParseException { public static Tuple<XContentType, Object> convertToObject(BytesReference bytes) throws ElasticsearchParseException {
try { try {
XContentParser parser; XContentParser parser = XContentHelper.createParser(bytes);
XContentType contentType; return Tuple.tuple(parser.contentType(), readValue(parser, parser.nextToken()));
Compressor compressor = CompressorFactory.compressor(bytes);
if (compressor != null) {
StreamInput compressedStreamInput = compressor.streamInput(bytes.streamInput());
contentType = XContentFactory.xContentType(compressedStreamInput);
parser = XContentFactory.xContent(contentType).createParser(compressedStreamInput);
} else {
contentType = XContentFactory.xContentType(bytes);
parser = XContentFactory.xContent(contentType).createParser(bytes.streamInput());
}
return Tuple.tuple(contentType, readValue(parser, parser.nextToken()));
} catch (IOException e) { } catch (IOException e) {
throw new ElasticsearchParseException("Failed to parse content to map", e); throw new ElasticsearchParseException("Failed to parse content to map", e);
} }

View File

@ -32,6 +32,7 @@ import static org.mockito.Mockito.when;
public class CompareConditionSearchTests extends AbstractWatcherIntegrationTests { public class CompareConditionSearchTests extends AbstractWatcherIntegrationTests {
@Test @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/11692") //nocommit
public void testExecute_withAggs() throws Exception { public void testExecute_withAggs() throws Exception {
client().admin().indices().prepareCreate("my-index") client().admin().indices().prepareCreate("my-index")

View File

@ -49,6 +49,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTests
} }
@Test @Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/11692") //nocommit
public void testExecute_withAggs() throws Exception { public void testExecute_withAggs() throws Exception {
client().admin().indices().prepareCreate("my-index") client().admin().indices().prepareCreate("my-index")

View File

@ -72,16 +72,17 @@ public class SearchInputTests extends ElasticsearchIntegrationTest {
@Override @Override
public Settings nodeSettings(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Path tempDir = createTempDir(); final Path tempDir = createTempDir();
Path configPath = tempDir.resolve("config").resolve("scripts"); final Path configPath = tempDir.resolve("config");
final Path scriptPath = configPath.resolve("scripts");
try { try {
Files.createDirectories(configPath); Files.createDirectories(scriptPath);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("failed to create config dir"); throw new RuntimeException("failed to create config dir");
} }
try (InputStream stream = SearchInputTests.class.getResourceAsStream("/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache"); try (InputStream stream = SearchInputTests.class.getResourceAsStream("/org/elasticsearch/watcher/input/search/config/scripts/test_disk_template.mustache");
OutputStream out = Files.newOutputStream(configPath.resolve("test_disk_template.mustache"))) { OutputStream out = Files.newOutputStream(scriptPath.resolve("test_disk_template.mustache"))) {
Streams.copy(stream, out); Streams.copy(stream, out);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("failed to copy mustache template"); throw new RuntimeException("failed to copy mustache template");

View File

@ -60,7 +60,7 @@ public class WatcherDateTimeUtilsTests extends ElasticsearchTestCase {
.put(value + "s", TimeValue.timeValueSeconds(value)) .put(value + "s", TimeValue.timeValueSeconds(value))
.put(value + "m", TimeValue.timeValueMinutes(value)) .put(value + "m", TimeValue.timeValueMinutes(value))
.put(value + "h", TimeValue.timeValueHours(value)) .put(value + "h", TimeValue.timeValueHours(value))
.put(value + "", TimeValue.timeValueMillis(value)) // .put(value + "", TimeValue.timeValueMillis(value)) nocommit this is not allowed in 2.0 anymore - we need to upgrade those settings?
.build(); .build();
String key = randomFrom(values.keySet().toArray(new String[values.size()])); String key = randomFrom(values.keySet().toArray(new String[values.size()]));
@ -82,7 +82,7 @@ public class WatcherDateTimeUtilsTests extends ElasticsearchTestCase {
.put(value + "s", TimeValue.timeValueSeconds(value)) .put(value + "s", TimeValue.timeValueSeconds(value))
.put(value + "m", TimeValue.timeValueMinutes(value)) .put(value + "m", TimeValue.timeValueMinutes(value))
.put(value + "h", TimeValue.timeValueHours(value)) .put(value + "h", TimeValue.timeValueHours(value))
.put(value + "", TimeValue.timeValueMillis(value)) //.put(value + "", TimeValue.timeValueMillis(value)) nocommit this is not allowed in 2.0 anymore - we need to upgrade those settings?
.build(); .build();
String key = randomFrom(values.keySet().toArray(new String[values.size()])); String key = randomFrom(values.keySet().toArray(new String[values.size()]));

View File

@ -654,7 +654,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg
" cluster: cluster:monitor/nodes/info, cluster:monitor/nodes/liveness\n" + " cluster: cluster:monitor/nodes/info, cluster:monitor/nodes/liveness\n" +
"\n" + "\n" +
"monitor:\n" + "monitor:\n" +
" cluster: monitor_watcher, cluster:monitor/nodes/info, cluster:monitor/nodes/liveness\\\n" " cluster: monitor_watcher, cluster:monitor/nodes/info, cWatcherDateTimeUtilsTestsluster:monitor/nodes/liveness\\\n"
; ;

View File

@ -70,16 +70,17 @@ public class SearchTransformTests extends ElasticsearchIntegrationTest {
@Override @Override
public Settings nodeSettings(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Path tempDir = createTempDir(); final Path tempDir = createTempDir();
Path configPath = tempDir.resolve("config").resolve("scripts"); final Path configPath = tempDir.resolve("config");
final Path scriptPath = configPath.resolve("scripts");
try { try {
Files.createDirectories(configPath); Files.createDirectories(scriptPath);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("failed to create config dir"); throw new RuntimeException("failed to create config dir");
} }
try (InputStream stream = SearchTransformTests.class.getResourceAsStream("/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache"); try (InputStream stream = SearchTransformTests.class.getResourceAsStream("/org/elasticsearch/watcher/transform/search/config/scripts/test_disk_template.mustache");
OutputStream out = Files.newOutputStream(configPath.resolve("test_disk_template.mustache"))) { OutputStream out = Files.newOutputStream(scriptPath.resolve("test_disk_template.mustache"))) {
Streams.copy(stream, out); Streams.copy(stream, out);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("failed to copy mustache template"); throw new RuntimeException("failed to copy mustache template");

View File

@ -51,7 +51,7 @@ public class WatchLockServiceTests extends ElasticsearchTestCase {
try { try {
lockService.acquire("_name"); lockService.acquire("_name");
fail("exception expected"); fail("exception expected");
} catch (IllegalStateException e) { } catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("Lock already acquired")); assertThat(e.getMessage(), containsString("Lock already acquired"));
} }
lock1.release(); lock1.release();