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));
|
CallOptions.DEFAULT.withDeadlineAfter(rpcTimeoutSec, TimeUnit.SECONDS));
|
||||||
call.start(
|
call.start(
|
||||||
new ClientCall.Listener<SimpleResponse>() {
|
new ClientCall.Listener<SimpleResponse>() {
|
||||||
private String serverId;
|
private String hostname;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(SimpleResponse response) {
|
public void onMessage(SimpleResponse response) {
|
||||||
serverId = response.getServerId();
|
hostname = response.getHostname();
|
||||||
// TODO(ericgribkoff) Currently some test environments cannot access the stats RPC
|
// TODO(ericgribkoff) Currently some test environments cannot access the stats RPC
|
||||||
// service and rely on parsing stdout.
|
// service and rely on parsing stdout.
|
||||||
if (printResponse) {
|
if (printResponse) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Greeting: Hello world, this is "
|
"Greeting: Hello world, this is "
|
||||||
+ response.getHostname()
|
+ hostname
|
||||||
+ ", from "
|
+ ", from "
|
||||||
+ call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
|
+ call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +227,7 @@ public final class XdsTestClient {
|
||||||
@Override
|
@Override
|
||||||
public void onClose(Status status, Metadata trailers) {
|
public void onClose(Status status, Metadata trailers) {
|
||||||
for (XdsStatsWatcher watcher : savedWatchers) {
|
for (XdsStatsWatcher watcher : savedWatchers) {
|
||||||
watcher.rpcCompleted(requestId, serverId);
|
watcher.rpcCompleted(requestId, hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -295,14 +295,14 @@ public final class XdsTestClient {
|
||||||
this.endId = endId;
|
this.endId = endId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpcCompleted(long requestId, @Nullable String serverId) {
|
void rpcCompleted(long requestId, @Nullable String hostname) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (startId <= requestId && requestId < endId) {
|
if (startId <= requestId && requestId < endId) {
|
||||||
if (serverId != null) {
|
if (hostname != null) {
|
||||||
if (rpcsByPeer.containsKey(serverId)) {
|
if (rpcsByPeer.containsKey(hostname)) {
|
||||||
rpcsByPeer.put(serverId, rpcsByPeer.get(serverId) + 1);
|
rpcsByPeer.put(hostname, rpcsByPeer.get(hostname) + 1);
|
||||||
} else {
|
} else {
|
||||||
rpcsByPeer.put(serverId, 1);
|
rpcsByPeer.put(hostname, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
noRemotePeer += 1;
|
noRemotePeer += 1;
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,14 @@ public final class XdsTestServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
|
private class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
|
||||||
private String host = "";
|
private final String host;
|
||||||
|
|
||||||
private TestServiceImpl() {
|
private TestServiceImpl() {
|
||||||
try {
|
try {
|
||||||
host = InetAddress.getLocalHost().getHostName();
|
host = InetAddress.getLocalHost().getHostName();
|
||||||
} catch (UnknownHostException e) {
|
} 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