-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML-DataFrame] fix wire serialization issues in data frame response o…
…bjects (#39790) fix wire serialization issues in data frame response objects
- Loading branch information
Hendrik Muhs
authored
Mar 7, 2019
1 parent
78c27b3
commit 4cab8ec
Showing
14 changed files
with
241 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...g/elasticsearch/xpack/core/dataframe/action/AbstractWireSerializingDataFrameTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.search.SearchModule; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
import org.junit.Before; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
public abstract class AbstractWireSerializingDataFrameTestCase<T extends Writeable> extends AbstractWireSerializingTestCase<T> { | ||
/** | ||
* Test case that ensures aggregation named objects are registered | ||
*/ | ||
private NamedWriteableRegistry namedWriteableRegistry; | ||
private NamedXContentRegistry namedXContentRegistry; | ||
|
||
@Before | ||
public void registerAggregationNamedObjects() throws Exception { | ||
// register aggregations as NamedWriteable | ||
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList()); | ||
|
||
namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables()); | ||
namedXContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents()); | ||
} | ||
|
||
@Override | ||
protected NamedWriteableRegistry getNamedWriteableRegistry() { | ||
return namedWriteableRegistry; | ||
} | ||
|
||
@Override | ||
protected NamedXContentRegistry xContentRegistry() { | ||
return namedXContentRegistry; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...lasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformActionResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
import org.elasticsearch.xpack.core.dataframe.action.DeleteDataFrameTransformAction.Response; | ||
|
||
public class DeleteDataFrameTransformActionResponseTests extends AbstractWireSerializingDataFrameTestCase<Response> { | ||
@Override | ||
protected Response createTestInstance() { | ||
return new Response(randomBoolean()); | ||
} | ||
|
||
@Override | ||
protected Reader<Response> instanceReader() { | ||
return Response::new; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ticsearch/xpack/core/dataframe/action/GetDataFrameTransformsStatsActionResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
import org.elasticsearch.xpack.core.dataframe.action.GetDataFrameTransformsStatsAction.Response; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformStateAndStats; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformStateAndStatsTests; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class GetDataFrameTransformsStatsActionResponseTests extends AbstractWireSerializingDataFrameTestCase<Response> { | ||
@Override | ||
protected Response createTestInstance() { | ||
List<DataFrameTransformStateAndStats> stats = new ArrayList<>(); | ||
for (int i = 0; i < randomInt(10); ++i) { | ||
stats.add(DataFrameTransformStateAndStatsTests.randomDataFrameTransformStateAndStats()); | ||
} | ||
|
||
return new Response(stats); | ||
} | ||
|
||
@Override | ||
protected Reader<Response> instanceReader() { | ||
return Response::new; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...search/xpack/core/dataframe/action/PreviewDataFrameTransformsActionResponseWireTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
import org.elasticsearch.xpack.core.dataframe.action.PreviewDataFrameTransformAction.Response; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PreviewDataFrameTransformsActionResponseWireTests extends AbstractWireSerializingDataFrameTestCase<Response> { | ||
|
||
@Override | ||
protected Response createTestInstance() { | ||
int size = randomIntBetween(0, 10); | ||
List<Map<String, Object>> data = new ArrayList<>(size); | ||
for (int i = 0; i < size; i++) { | ||
Map<String, Object> datum = new HashMap<>(); | ||
Map<String, Object> entry = new HashMap<>(); | ||
entry.put("value1", randomIntBetween(1, 100)); | ||
datum.put(randomAlphaOfLength(10), entry); | ||
data.add(datum); | ||
} | ||
return new Response(data); | ||
} | ||
|
||
@Override | ||
protected Reader<Response> instanceReader() { | ||
return Response::new; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...g/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformActionResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.test.AbstractStreamableTestCase; | ||
import org.elasticsearch.xpack.core.dataframe.action.PutDataFrameTransformAction.Response; | ||
|
||
public class PutDataFrameTransformActionResponseTests extends AbstractStreamableTestCase<Response> { | ||
|
||
@Override | ||
protected Response createBlankInstance() { | ||
return new Response(); | ||
} | ||
|
||
@Override | ||
protected Response createTestInstance() { | ||
return new Response(randomBoolean()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformActionResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
import org.elasticsearch.xpack.core.dataframe.action.StartDataFrameTransformAction.Response; | ||
|
||
public class StartDataFrameTransformActionResponseTests extends AbstractWireSerializingDataFrameTestCase<Response> { | ||
|
||
@Override | ||
protected Response createTestInstance() { | ||
return new Response(randomBoolean()); | ||
} | ||
|
||
@Override | ||
protected Reader<Response> instanceReader() { | ||
return Response::new; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
.../elasticsearch/xpack/core/dataframe/action/StopDataFrameTransformActionResponseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.dataframe.action; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
import org.elasticsearch.xpack.core.dataframe.action.StopDataFrameTransformAction.Response; | ||
|
||
public class StopDataFrameTransformActionResponseTests extends AbstractWireSerializingDataFrameTestCase<Response> { | ||
|
||
@Override | ||
protected Response createTestInstance() { | ||
return new Response(randomBoolean()); | ||
} | ||
|
||
@Override | ||
protected Reader<Response> instanceReader() { | ||
return Response::new; | ||
} | ||
|
||
} |