|
6 | 6 |
|
7 | 7 | package org.elasticsearch.xpack.core.transform.transforms; |
8 | 8 |
|
| 9 | +import org.elasticsearch.Version; |
| 10 | +import org.elasticsearch.common.io.stream.BytesStreamOutput; |
| 11 | +import org.elasticsearch.common.io.stream.StreamInput; |
9 | 12 | import org.elasticsearch.common.io.stream.Writeable.Reader; |
10 | 13 | import org.elasticsearch.common.xcontent.XContentParser; |
11 | 14 | import org.elasticsearch.test.AbstractSerializingTestCase; |
12 | 15 |
|
13 | 16 | import java.io.IOException; |
14 | 17 | import java.util.function.Predicate; |
15 | 18 |
|
| 19 | +import static org.elasticsearch.xpack.core.transform.transforms.TransformStats.State.STARTED; |
| 20 | +import static org.hamcrest.Matchers.equalTo; |
| 21 | + |
16 | 22 | public class TransformStatsTests extends AbstractSerializingTestCase<TransformStats> { |
17 | 23 |
|
18 | 24 | public static TransformStats randomDataFrameTransformStats() { |
@@ -53,4 +59,28 @@ protected String[] getShuffleFieldsExceptions() { |
53 | 59 | protected Predicate<String> getRandomFieldsExcludeFilter() { |
54 | 60 | return field -> !field.isEmpty(); |
55 | 61 | } |
| 62 | + |
| 63 | + public void testBwcWith73() throws IOException { |
| 64 | + for(int i = 0; i < NUMBER_OF_TEST_RUNS; i++) { |
| 65 | + TransformStats stats = new TransformStats("bwc-id", |
| 66 | + STARTED, |
| 67 | + randomBoolean() ? null : randomAlphaOfLength(100), |
| 68 | + randomBoolean() ? null : NodeAttributeTests.randomNodeAttributes(), |
| 69 | + new TransformIndexerStats(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), |
| 70 | + new TransformCheckpointingInfo( |
| 71 | + new TransformCheckpointStats(0, null, null, 10, 100), |
| 72 | + new TransformCheckpointStats(0, null, null, 100, 1000), |
| 73 | + // changesLastDetectedAt aren't serialized back |
| 74 | + 100, null)); |
| 75 | + try (BytesStreamOutput output = new BytesStreamOutput()) { |
| 76 | + output.setVersion(Version.V_7_3_0); |
| 77 | + stats.writeTo(output); |
| 78 | + try (StreamInput in = output.bytes().streamInput()) { |
| 79 | + in.setVersion(Version.V_7_3_0); |
| 80 | + TransformStats statsFromOld = new TransformStats(in); |
| 81 | + assertThat(statsFromOld, equalTo(stats)); |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
56 | 86 | } |
0 commit comments