Repository navigation
Conversation
|
When we get the path in the REST catalog tests we use e.g. |
|
cc @nastra as the owner of the configurable namespace separator change |
31d1ba0 to
019e40f
Compare
019e40f to
bb52da6
Compare
| catalog.createTable(table, SCHEMA); | ||
|
|
||
| ResourcePaths paths = ResourcePaths.forCatalogProperties(ImmutableMap.of()); | ||
| assertThat(paths.tables(ns)) |
There was a problem hiding this comment.
it seems like what you're really trying to test is
@Test
public void nestedNamespaceWithLegacyAndNewSeparator() {
Namespace namespace = Namespace.of("first", "second", "third");
String legacySeparator = RESTUtil.NAMESPACE_SEPARATOR_URLENCODED_UTF_8;
String newSeparator = "%2E";
// legacy separator is always used by default, so no need to configure it
ResourcePaths withLegacySeparator = ResourcePaths.forCatalogProperties(ImmutableMap.of());
ResourcePaths withNewSeparator =
ResourcePaths.forCatalogProperties(
ImmutableMap.of(RESTCatalogProperties.NAMESPACE_SEPARATOR, newSeparator));
// old client would call encodeNamespace without specifying a separator when constructing a
// resource path
String legacyEncodedNamespace = RESTUtil.encodeNamespace(namespace);
assertThat(withLegacySeparator.namespace(namespace))
.contains(legacyEncodedNamespace)
.contains(legacySeparator);
// old client would decode without specifying the separator
assertThat(RESTUtil.decodeNamespace(legacyEncodedNamespace)).isEqualTo(namespace);
// new server would decode the namespace using the new separator
assertThat(RESTUtil.decodeNamespace(legacyEncodedNamespace, newSeparator)).isEqualTo(namespace);
// new client would call encodeNamespace with specifying a separator when constructing a
// resource path
String newEncodedSeparator = RESTUtil.encodeNamespace(namespace, newSeparator);
assertThat(withNewSeparator.namespace(namespace))
.contains(newEncodedSeparator)
.contains(newSeparator);
// new server would decode the namespace using the new separator
assertThat(RESTUtil.decodeNamespace(newEncodedSeparator, newSeparator)).isEqualTo(namespace);
}
In that case the test should probably live in TestResourcePaths
There was a problem hiding this comment.
@gaborkaszab can you also add ^ to TestResourcePaths
There was a problem hiding this comment.
Sure. I've split this into 2
bb52da6 to
b6da4d9
Compare
|
|
||
| RESTCatalog catalog = catalog(adapter); | ||
|
|
||
| // Do verification with paths using the default namespace separator. |
There was a problem hiding this comment.
| // Do verification with paths using the default namespace separator. | |
| // Do verification with paths using the legacy namespace separator. |
There was a problem hiding this comment.
In fact with the suggested naming, I think this comment is redundant, so I'm removing it.
|
|
||
| @Test | ||
| public void testClientNamespaceSeparatorOverridden() { | ||
| RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); |
There was a problem hiding this comment.
you might want to add a comment that says that the server now always sends back the separator in the config response so that this is clear here
There was a problem hiding this comment.
Done. I added an extra check also to verify the override is sent by the adapter. Makes the test more future proof, however, this may be an overkill. Let me know and I'll remove the check
|
|
||
| catalog.createNamespace(nestedNamespace); | ||
|
|
||
| catalog.createTable(table, SCHEMA); |
There was a problem hiding this comment.
we don't really need the table creation here
There was a problem hiding this comment.
I use this so that I can also verify that the paths use the desired namespace separators. I know you've commented that it rather belongs to TestResourcePaths, but in general I think whenever an end-to-end scenario is easy to do, it makes sense to add test coverage there (besides narrower unit testing). In this case it's pretty simple to cover, and add more test coverage not just to ResourcePaths but also to the RESTCatalog code around creating and using the paths. This gives use more complete tests here: the paths and the params together.
b6da4d9 to
8c040b8
Compare
| ConfigResponse configResponse = (ConfigResponse) invocation.callRealMethod(); | ||
|
|
||
| assertThat(configResponse.overrides()) | ||
| .contains( |
There was a problem hiding this comment.
you can just use containsEntry(...) directly here
The resource paths used for comparisons in the REST catalog test use different namespace separator than the test REST catalogs. This PR brings them in line.
8c040b8 to
d379d99
Compare
gaborkaszab
left a comment
There was a problem hiding this comment.
Thanks for looking, @nastra !
| ConfigResponse configResponse = (ConfigResponse) invocation.callRealMethod(); | ||
|
|
||
| assertThat(configResponse.overrides()) | ||
| .contains( |
|
|
||
| RESTCatalog catalog = catalog(adapter); | ||
|
|
||
| // Do verification with paths using the default namespace separator. |
There was a problem hiding this comment.
In fact with the suggested naming, I think this comment is redundant, so I'm removing it.
| catalog.createTable(table, SCHEMA); | ||
|
|
||
| ResourcePaths paths = ResourcePaths.forCatalogProperties(ImmutableMap.of()); | ||
| assertThat(paths.tables(ns)) |
There was a problem hiding this comment.
Sure. I've split this into 2
|
Thanks for reviewing, @nastra ! |
Co-authored-by: Eduard Tudenhoefner <etudenhoefner@gmail.com>
The resource paths used for comparisons in the REST catalog test use different namespace separator than the test REST catalogs. This PR brings them in line.