|
8 | 8 | package org.elasticsearch.xpack.core.inference.action; |
9 | 9 |
|
10 | 10 | import org.apache.http.pool.PoolStats; |
| 11 | +import org.elasticsearch.TransportVersion; |
| 12 | +import org.elasticsearch.TransportVersions; |
11 | 13 | import org.elasticsearch.cluster.node.DiscoveryNode; |
12 | 14 | import org.elasticsearch.cluster.node.DiscoveryNodeUtils; |
13 | 15 | import org.elasticsearch.common.Strings; |
14 | 16 | import org.elasticsearch.common.io.stream.NamedWriteableRegistry; |
15 | 17 | import org.elasticsearch.common.io.stream.StreamInput; |
16 | 18 | import org.elasticsearch.common.io.stream.StreamOutput; |
17 | 19 | import org.elasticsearch.common.io.stream.Writeable; |
18 | | -import org.elasticsearch.test.AbstractWireSerializingTestCase; |
19 | 20 | import org.elasticsearch.xcontent.XContentBuilder; |
20 | 21 | import org.elasticsearch.xpack.core.inference.SerializableStats; |
| 22 | +import org.elasticsearch.xpack.core.ml.AbstractBWCWireSerializationTestCase; |
21 | 23 |
|
22 | 24 | import java.io.IOException; |
23 | 25 | import java.io.UnsupportedEncodingException; |
24 | 26 | import java.util.List; |
25 | 27 |
|
26 | | -public class GetInferenceDiagnosticsActionNodeResponseTests extends AbstractWireSerializingTestCase< |
| 28 | +public class GetInferenceDiagnosticsActionNodeResponseTests extends AbstractBWCWireSerializationTestCase< |
27 | 29 | GetInferenceDiagnosticsAction.NodeResponse> { |
28 | 30 | public static GetInferenceDiagnosticsAction.NodeResponse createRandom() { |
29 | 31 | DiscoveryNode node = DiscoveryNodeUtils.create("id"); |
@@ -130,4 +132,25 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws |
130 | 132 | return builder.startObject().field("count", count).endObject(); |
131 | 133 | } |
132 | 134 | } |
| 135 | + |
| 136 | + @Override |
| 137 | + protected GetInferenceDiagnosticsAction.NodeResponse mutateInstanceForVersion( |
| 138 | + GetInferenceDiagnosticsAction.NodeResponse instance, |
| 139 | + TransportVersion version |
| 140 | + ) { |
| 141 | + if (version.before(TransportVersions.ML_INFERENCE_ENDPOINT_CACHE)) { |
| 142 | + return new GetInferenceDiagnosticsAction.NodeResponse( |
| 143 | + instance.getNode(), |
| 144 | + new PoolStats( |
| 145 | + instance.getConnectionPoolStats().getLeasedConnections(), |
| 146 | + instance.getConnectionPoolStats().getPendingConnections(), |
| 147 | + instance.getConnectionPoolStats().getAvailableConnections(), |
| 148 | + instance.getConnectionPoolStats().getMaxConnections() |
| 149 | + ), |
| 150 | + null |
| 151 | + ); |
| 152 | + } else { |
| 153 | + return instance; |
| 154 | + } |
| 155 | + } |
133 | 156 | } |
0 commit comments