mirror of https://github.com/grpc/grpc-java.git
interop-testing: use server hostname instead of id for xds test (#6639)
This commit is contained in:
parent
751faa6faa
commit
e5745a514f
|
|
@ -208,17 +208,17 @@ public final class XdsTestClient {
|
|||
CallOptions.DEFAULT.withDeadlineAfter(rpcTimeoutSec, TimeUnit.SECONDS));
|
||||
call.start(
|
||||
new ClientCall.Listener<SimpleResponse>() {
|
||||
private String serverId;
|
||||
private String hostname;
|
||||
|
||||
@Override
|
||||
public void onMessage(SimpleResponse response) {
|
||||
serverId = response.getServerId();
|
||||
hostname = response.getHostname();
|
||||
// TODO(ericgribkoff) Currently some test environments cannot access the stats RPC
|
||||
// service and rely on parsing stdout.
|
||||
if (printResponse) {
|
||||
System.out.println(
|
||||
"Greeting: Hello world, this is "
|
||||
+ response.getHostname()
|
||||
+ hostname
|
||||
+ ", from "
|
||||
+ call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ public final class XdsTestClient {
|
|||
@Override
|
||||
public void onClose(Status status, Metadata trailers) {
|
||||
for (XdsStatsWatcher watcher : savedWatchers) {
|
||||
watcher.rpcCompleted(requestId, serverId);
|
||||
watcher.rpcCompleted(requestId, hostname);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -295,14 +295,14 @@ public final class XdsTestClient {
|
|||
this.endId = endId;
|
||||
}
|
||||
|
||||
void rpcCompleted(long requestId, @Nullable String serverId) {
|
||||
void rpcCompleted(long requestId, @Nullable String hostname) {
|
||||
synchronized (lock) {
|
||||
if (startId <= requestId && requestId < endId) {
|
||||
if (serverId != null) {
|
||||
if (rpcsByPeer.containsKey(serverId)) {
|
||||
rpcsByPeer.put(serverId, rpcsByPeer.get(serverId) + 1);
|
||||
if (hostname != null) {
|
||||
if (rpcsByPeer.containsKey(hostname)) {
|
||||
rpcsByPeer.put(hostname, rpcsByPeer.get(hostname) + 1);
|
||||
} else {
|
||||
rpcsByPeer.put(serverId, 1);
|
||||
rpcsByPeer.put(hostname, 1);
|
||||
}
|
||||
} else {
|
||||
noRemotePeer += 1;
|
||||
|
|
|
|||
|
|
@ -124,13 +124,14 @@ public final class XdsTestServer {
|
|||
}
|
||||
|
||||
private class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
|
||||
private String host = "";
|
||||
private final String host;
|
||||
|
||||
private TestServiceImpl() {
|
||||
try {
|
||||
host = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
logger.log(Level.WARNING, "Failed to get host", e);
|
||||
logger.log(Level.SEVERE, "Failed to get host", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue