Skip to content

Commit

Permalink
Remove old HLRC base test case (#48714)
Browse files Browse the repository at this point in the history
This commit finishes cleaning up the AbstractHlrcXContentTestCase work
and removes this class. All classes that were using this are now using
the updated base class.

Ref #39745
  • Loading branch information
hub-cap authored Oct 30, 2019
1 parent f50e5d8 commit fef6c28
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 144 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,42 @@

package org.elasticsearch.client.transform.transforms.hlrc;

import org.elasticsearch.client.AbstractHlrcXContentTestCase;
import org.elasticsearch.client.AbstractResponseTestCase;
import org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;
import java.time.Instant;
import java.util.function.Predicate;

public class TransformCheckpointingInfoTests extends AbstractHlrcXContentTestCase<
TransformCheckpointingInfo,
org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo> {
import static org.elasticsearch.client.transform.transforms.hlrc.TransformStatsTests.assertTransformCheckpointInfo;

public static TransformCheckpointingInfo fromHlrc(
org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo instance) {
return new TransformCheckpointingInfo(
TransformCheckpointStatsTests.fromHlrc(instance.getLast()),
TransformCheckpointStatsTests.fromHlrc(instance.getNext()),
instance.getOperationsBehind(),
instance.getChangesLastDetectedAt());
}

@Override
public org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo doHlrcParseInstance(XContentParser parser) {
return org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo.fromXContent(parser);
}

@Override
public TransformCheckpointingInfo convertHlrcToInternal(
org.elasticsearch.client.transform.transforms.TransformCheckpointingInfo instance) {
return fromHlrc(instance);
}
public class TransformCheckpointingInfoTests extends AbstractResponseTestCase<
org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo,
TransformCheckpointingInfo> {

public static TransformCheckpointingInfo randomTransformCheckpointingInfo() {
return new TransformCheckpointingInfo(
public static org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo randomTransformCheckpointingInfo() {
return new org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo(
TransformCheckpointStatsTests.randomTransformCheckpointStats(),
TransformCheckpointStatsTests.randomTransformCheckpointStats(),
randomNonNegativeLong(),
randomBoolean() ? null : Instant.ofEpochMilli(randomNonNegativeLong()));
}

@Override
protected TransformCheckpointingInfo createTestInstance() {
protected org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo
createServerTestInstance(XContentType xContentType) {
return randomTransformCheckpointingInfo();
}

@Override
protected TransformCheckpointingInfo doParseInstance(XContentParser parser) throws IOException {
protected TransformCheckpointingInfo doParseToClientInstance(XContentParser parser) throws IOException {
return TransformCheckpointingInfo.fromXContent(parser);
}

@Override
protected boolean supportsUnknownFields() {
return true;
}

@Override
protected Predicate<String> getRandomFieldsExcludeFilter() {
return field -> field.contains("position");
protected void assertInstances(org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo serverTestInstance,
TransformCheckpointingInfo clientInstance) {
assertTransformCheckpointInfo(serverTestInstance, clientInstance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,22 @@

package org.elasticsearch.client.transform.transforms.hlrc;

import org.elasticsearch.client.AbstractHlrcXContentTestCase;
import org.elasticsearch.client.AbstractResponseTestCase;
import org.elasticsearch.client.transform.transforms.TransformIndexerStats;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

public class TransformIndexerStatsTests extends AbstractHlrcXContentTestCase<
TransformIndexerStats,
org.elasticsearch.client.transform.transforms.TransformIndexerStats> {
import static org.elasticsearch.client.transform.transforms.hlrc.TransformStatsTests.assertTransformIndexerStats;

public static TransformIndexerStats fromHlrc(
org.elasticsearch.client.transform.transforms.TransformIndexerStats instance) {
return new TransformIndexerStats(
instance.getNumPages(),
instance.getNumDocuments(),
instance.getOutputDocuments(),
instance.getNumInvocations(),
instance.getIndexTime(),
instance.getSearchTime(),
instance.getIndexTotal(),
instance.getSearchTotal(),
instance.getIndexFailures(),
instance.getSearchFailures(),
instance.getExpAvgCheckpointDurationMs(),
instance.getExpAvgDocumentsIndexed(),
instance.getExpAvgDocumentsProcessed());
}
public class TransformIndexerStatsTests extends AbstractResponseTestCase<
org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats,
TransformIndexerStats> {

@Override
public org.elasticsearch.client.transform.transforms.TransformIndexerStats doHlrcParseInstance(XContentParser parser)
throws IOException {
return org.elasticsearch.client.transform.transforms.TransformIndexerStats.fromXContent(parser);
}

@Override
public TransformIndexerStats convertHlrcToInternal(
org.elasticsearch.client.transform.transforms.TransformIndexerStats instance) {
return fromHlrc(instance);
}

public static TransformIndexerStats randomStats() {
return new TransformIndexerStats(randomLongBetween(10L, 10000L),
protected org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats createServerTestInstance(XContentType xContentType) {
return new org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats(randomLongBetween(10L, 10000L),
randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L),
randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L), randomLongBetween(0L, 10000L),
randomLongBetween(0L, 10000L),
Expand All @@ -70,18 +44,13 @@ public static TransformIndexerStats randomStats() {
}

@Override
protected TransformIndexerStats createTestInstance() {
return randomStats();
}

@Override
protected TransformIndexerStats doParseInstance(XContentParser parser) throws IOException {
protected TransformIndexerStats doParseToClientInstance(XContentParser parser) throws IOException {
return TransformIndexerStats.fromXContent(parser);
}

@Override
protected boolean supportsUnknownFields() {
return true;
protected void assertInstances(org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats serverTestInstance,
TransformIndexerStats clientInstance) {
assertTransformIndexerStats(serverTestInstance, clientInstance);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void assertNodeAttributes(org.elasticsearch.xpack.core.transform.transfo
assertThat(serverTestInstance.getTransportAddress(), equalTo(clientInstance.getTransportAddress()));
}

private void assertTransformProgress(org.elasticsearch.xpack.core.transform.transforms.TransformProgress serverTestInstance,
public static void assertTransformProgress(org.elasticsearch.xpack.core.transform.transforms.TransformProgress serverTestInstance,
TransformProgress clientInstance) {
if (serverTestInstance == null || clientInstance == null) {
assertNull(serverTestInstance);
Expand All @@ -115,34 +115,35 @@ private void assertTransformProgress(org.elasticsearch.xpack.core.transform.tran
assertThat(serverTestInstance.getDocumentsIndexed(), equalTo(clientInstance.getDocumentsIndexed()));
}

private void assertPosition(org.elasticsearch.xpack.core.transform.transforms.TransformIndexerPosition serverTestInstance,
public static void assertPosition(org.elasticsearch.xpack.core.transform.transforms.TransformIndexerPosition serverTestInstance,
TransformIndexerPosition clientInstance) {
assertThat(serverTestInstance.getIndexerPosition(), equalTo(clientInstance.getIndexerPosition()));
assertThat(serverTestInstance.getBucketsPosition(), equalTo(clientInstance.getBucketsPosition()));
}


private void assertTransformCheckpointStats(
org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointStats serverTestInstance,
TransformCheckpointStats clientInstance) {
public static void assertTransformCheckpointStats(
org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointStats serverTestInstance,
TransformCheckpointStats clientInstance) {
assertTransformProgress(serverTestInstance.getCheckpointProgress(), clientInstance.getCheckpointProgress());
assertThat(serverTestInstance.getCheckpoint(), equalTo(clientInstance.getCheckpoint()));
assertPosition(serverTestInstance.getPosition(), clientInstance.getPosition());
assertThat(serverTestInstance.getTimestampMillis(), equalTo(clientInstance.getTimestampMillis()));
assertThat(serverTestInstance.getTimeUpperBoundMillis(), equalTo(clientInstance.getTimeUpperBoundMillis()));
}

private void assertTransformCheckpointInfo(
org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo serverTestInstance,
TransformCheckpointingInfo clientInstance) {
public static void assertTransformCheckpointInfo(
org.elasticsearch.xpack.core.transform.transforms.TransformCheckpointingInfo serverTestInstance,
TransformCheckpointingInfo clientInstance) {
assertTransformCheckpointStats(serverTestInstance.getNext(), clientInstance.getNext());
assertTransformCheckpointStats(serverTestInstance.getLast(), clientInstance.getLast());
assertThat(serverTestInstance.getChangesLastDetectedAt(), equalTo(clientInstance.getChangesLastDetectedAt()));
assertThat(serverTestInstance.getOperationsBehind(), equalTo(clientInstance.getOperationsBehind()));
}

private void assertTransformIndexerStats(org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats serverTestInstance,
TransformIndexerStats clientInstance) {
public static void assertTransformIndexerStats(
org.elasticsearch.xpack.core.transform.transforms.TransformIndexerStats serverTestInstance,
TransformIndexerStats clientInstance) {
assertThat(serverTestInstance.getExpAvgCheckpointDurationMs(), equalTo(clientInstance.getExpAvgCheckpointDurationMs()));
assertThat(serverTestInstance.getExpAvgDocumentsProcessed(), equalTo(clientInstance.getExpAvgDocumentsProcessed()));
assertThat(serverTestInstance.getExpAvgDocumentsIndexed(), equalTo(clientInstance.getExpAvgDocumentsIndexed()));
Expand Down

0 comments on commit fef6c28

Please sign in to comment.