Skip to content

Commit

Permalink
Add tests for clientScope being set
Browse files Browse the repository at this point in the history
  • Loading branch information
larry-safran committed Aug 21, 2024
1 parent 7ed5914 commit 9f6c61f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xds/src/test/java/io/grpc/xds/CsdsServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class CsdsServiceTest {
private static final XdsResourceType<?> CDS = XdsClusterResource.getInstance();
private static final XdsResourceType<?> RDS = XdsRouteConfigureResource.getInstance();
private static final XdsResourceType<?> EDS = XdsEndpointResource.getInstance();
public static final String FAKE_CLIENT_SCOPE = "fake";

@RunWith(JUnit4.class)
public static class ServiceTests {
Expand Down Expand Up @@ -273,6 +274,7 @@ private void verifyResponse(ClientStatusResponse response) {
ClientConfig clientConfig = response.getConfig(0);
verifyClientConfigNode(clientConfig);
verifyClientConfigNoResources(XDS_CLIENT_NO_RESOURCES, clientConfig);
assertThat(clientConfig.getClientScope()).isEmpty();
}

private void verifyRequestInvalidResponseStatus(Status status) {
Expand Down Expand Up @@ -351,9 +353,11 @@ public Map<String, XdsResourceType<?>> getSubscribedResourceTypesWithTypeUrl() {
);
}
};
ClientConfig clientConfig = CsdsService.getClientConfigForXdsClient(fakeXdsClient, "fake");
ClientConfig clientConfig = CsdsService.getClientConfigForXdsClient(fakeXdsClient,
FAKE_CLIENT_SCOPE);

verifyClientConfigNode(clientConfig);
assertThat(clientConfig.getClientScope()).isEqualTo(FAKE_CLIENT_SCOPE);

// Minimal verification to confirm that the data/metadata XdsClient provides,
// is propagated to the correct resource types.
Expand Down Expand Up @@ -392,9 +396,10 @@ public Map<String, XdsResourceType<?>> getSubscribedResourceTypesWithTypeUrl() {
@Test
public void getClientConfigForXdsClient_noSubscribedResources() throws InterruptedException {
ClientConfig clientConfig =
CsdsService.getClientConfigForXdsClient(XDS_CLIENT_NO_RESOURCES, "fake");
CsdsService.getClientConfigForXdsClient(XDS_CLIENT_NO_RESOURCES, FAKE_CLIENT_SCOPE);
verifyClientConfigNode(clientConfig);
verifyClientConfigNoResources(XDS_CLIENT_NO_RESOURCES, clientConfig);
assertThat(clientConfig.getClientScope()).isEqualTo(FAKE_CLIENT_SCOPE);
}
}

Expand Down

0 comments on commit 9f6c61f

Please sign in to comment.