-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add HLRC protocol tests for transform state and stats (#40766)
adds HLRC protocol tests for state and stats hrlc clients
- Loading branch information
Hendrik Muhs
authored
Apr 3, 2019
1 parent
c29cebb
commit 89d7b8a
Showing
8 changed files
with
163 additions
and
37 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
54 changes: 54 additions & 0 deletions
54
...csearch/xpack/core/dataframe/transforms/hlrc/DataFrameIndexerTransformStatsHlrcTests.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,54 @@ | ||
/* | ||
* 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.transforms.hlrc; | ||
|
||
import org.elasticsearch.common.xcontent.XContentParser; | ||
import org.elasticsearch.protocol.AbstractHlrcXContentTestCase; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameIndexerTransformStats; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameIndexerTransformStatsTests; | ||
|
||
import java.io.IOException; | ||
|
||
public class DataFrameIndexerTransformStatsHlrcTests extends AbstractHlrcXContentTestCase< | ||
DataFrameIndexerTransformStats, | ||
org.elasticsearch.client.dataframe.transforms.DataFrameIndexerTransformStats> { | ||
|
||
public static DataFrameIndexerTransformStats fromHlrc( | ||
org.elasticsearch.client.dataframe.transforms.DataFrameIndexerTransformStats instance) { | ||
return DataFrameIndexerTransformStats.withDefaultTransformId(instance.getNumPages(), instance.getNumDocuments(), | ||
instance.getOutputDocuments(), instance.getNumInvocations(), instance.getIndexTime(), instance.getSearchTime(), | ||
instance.getIndexTotal(), instance.getSearchTotal(), instance.getIndexFailures(), instance.getSearchFailures()); | ||
} | ||
|
||
@Override | ||
public org.elasticsearch.client.dataframe.transforms.DataFrameIndexerTransformStats doHlrcParseInstance(XContentParser parser) | ||
throws IOException { | ||
return org.elasticsearch.client.dataframe.transforms.DataFrameIndexerTransformStats.fromXContent(parser); | ||
} | ||
|
||
@Override | ||
public DataFrameIndexerTransformStats convertHlrcToInternal( | ||
org.elasticsearch.client.dataframe.transforms.DataFrameIndexerTransformStats instance) { | ||
return fromHlrc(instance); | ||
} | ||
|
||
@Override | ||
protected DataFrameIndexerTransformStats createTestInstance() { | ||
return DataFrameIndexerTransformStatsTests.randomStats(DataFrameIndexerTransformStats.DEFAULT_TRANSFORM_ID); | ||
} | ||
|
||
@Override | ||
protected DataFrameIndexerTransformStats doParseInstance(XContentParser parser) throws IOException { | ||
return DataFrameIndexerTransformStats.fromXContent(parser); | ||
} | ||
|
||
@Override | ||
protected boolean supportsUnknownFields() { | ||
return true; | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...search/xpack/core/dataframe/transforms/hlrc/DataFrameTransformStateAndStatsHlrcTests.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,57 @@ | ||
/* | ||
* 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.transforms.hlrc; | ||
|
||
import org.elasticsearch.common.xcontent.XContentParser; | ||
import org.elasticsearch.protocol.AbstractHlrcXContentTestCase; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameIndexerTransformStats; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformStateAndStats; | ||
import org.elasticsearch.xpack.core.dataframe.transforms.DataFrameTransformStateAndStatsTests; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Predicate; | ||
|
||
public class DataFrameTransformStateAndStatsHlrcTests extends AbstractHlrcXContentTestCase<DataFrameTransformStateAndStats, | ||
org.elasticsearch.client.dataframe.transforms.DataFrameTransformStateAndStats> { | ||
|
||
@Override | ||
public org.elasticsearch.client.dataframe.transforms.DataFrameTransformStateAndStats doHlrcParseInstance(XContentParser parser) | ||
throws IOException { | ||
return org.elasticsearch.client.dataframe.transforms.DataFrameTransformStateAndStats.fromXContent(parser); | ||
} | ||
|
||
@Override | ||
public DataFrameTransformStateAndStats convertHlrcToInternal( | ||
org.elasticsearch.client.dataframe.transforms.DataFrameTransformStateAndStats instance) { | ||
return new DataFrameTransformStateAndStats(instance.getId(), | ||
DataFrameTransformStateHlrcTests.fromHlrc(instance.getTransformState()), | ||
DataFrameIndexerTransformStatsHlrcTests.fromHlrc(instance.getTransformStats())); | ||
} | ||
|
||
@Override | ||
protected DataFrameTransformStateAndStats createTestInstance() { | ||
// the transform id is not part of HLRC as it's only to a field for internal storage, therefore use a default id | ||
return DataFrameTransformStateAndStatsTests | ||
.randomDataFrameTransformStateAndStats(DataFrameIndexerTransformStats.DEFAULT_TRANSFORM_ID); | ||
} | ||
|
||
@Override | ||
protected DataFrameTransformStateAndStats doParseInstance(XContentParser parser) throws IOException { | ||
return DataFrameTransformStateAndStats.PARSER.apply(parser, null); | ||
} | ||
|
||
@Override | ||
protected boolean supportsUnknownFields() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected Predicate<String> getRandomFieldsExcludeFilter() { | ||
return field -> field.equals("state.current_position"); | ||
} | ||
} | ||
|
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