Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Nessie to 0.71.0, adjust to Nessie client-builder updates #8607

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ kryo-shaded = "4.0.3"
microprofile-openapi-api = "3.1.1"
mockito = "4.11.0"
mockserver = "5.15.0"
nessie = "0.67.0"
nessie = "0.71.0"
netty-buffer = "4.1.97.Final"
netty-buffer-compat = "4.1.68.Final"
object-client-bundle = "3.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.projectnessie.client.NessieConfigConstants;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.client.config.NessieClientConfigSource;
import org.projectnessie.client.config.NessieClientConfigSources;
import org.projectnessie.client.http.HttpClientBuilder;
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.TableReference;
Expand Down Expand Up @@ -94,10 +96,11 @@ public void initialize(String name, Map<String, String> options) {
String requestedHash =
options.get(removePrefix.apply(NessieConfigConstants.CONF_NESSIE_REF_HASH));

NessieClientBuilder<?> nessieClientBuilder =
createNessieClientBuilder(
options.get(NessieConfigConstants.CONF_NESSIE_CLIENT_BUILDER_IMPL))
.fromConfig(x -> options.get(removePrefix.apply(x)));
NessieClientConfigSource configSource =
NessieClientConfigSources.mapConfigSource(options)
.fallbackTo(x -> options.get(removePrefix.apply(x)));
NessieClientBuilder nessieClientBuilder =
NessieClientBuilder.createClientBuilderFromSystemSettings(configSource);
// default version is set to v1.
final String apiVersion =
options.getOrDefault(removePrefix.apply(NessieUtil.CLIENT_API_VERSION), "1");
Expand Down Expand Up @@ -182,8 +185,8 @@ private String validateWarehouseLocation(String name, Map<String, String> catalo
return warehouseLocation;
}

private static NessieClientBuilder<?> createNessieClientBuilder(String customBuilder) {
NessieClientBuilder<?> clientBuilder;
private static NessieClientBuilder createNessieClientBuilder(String customBuilder) {
NessieClientBuilder clientBuilder;
if (customBuilder != null) {
try {
clientBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@

import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.net.URI;
import java.util.function.Function;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.TestCatalogUtil;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.Test;
import org.projectnessie.client.NessieClientBuilder;
import org.projectnessie.client.NessieClientBuilder.AbstractNessieClientBuilder;
import org.projectnessie.client.NessieConfigConstants;
import org.projectnessie.client.api.NessieApi;
import org.projectnessie.client.auth.NessieAuthentication;
import org.projectnessie.client.http.HttpClientBuilder;

public class TestCustomNessieClient extends BaseTestIceberg {
Expand Down Expand Up @@ -71,7 +68,6 @@ public void testUnnecessaryDefaultCustomClient() {

@Test
public void testNonExistentCustomClient() {
String nonExistingClass = "non.existent.ClientBuilderImpl";
assertThatThrownBy(
() -> {
NessieCatalog catalog = new NessieCatalog();
Expand All @@ -83,14 +79,14 @@ public void testNonExistentCustomClient() {
CatalogProperties.URI,
uri,
NessieConfigConstants.CONF_NESSIE_CLIENT_BUILDER_IMPL,
nonExistingClass));
"non.existent.ClientBuilderImpl"));
})
.isInstanceOf(RuntimeException.class)
.hasMessageContaining(nonExistingClass);
.hasMessageContaining("Cannot load Nessie client builder implementation class");
}

@Test
public void testCustomClient() {
public void testCustomClientByImpl() {
assertThatThrownBy(
() -> {
NessieCatalog catalog = new NessieCatalog();
Expand All @@ -108,6 +104,25 @@ public void testCustomClient() {
.hasMessage("BUILD CALLED");
}

@Test
public void testCustomClientByName() {
assertThatThrownBy(
() -> {
NessieCatalog catalog = new NessieCatalog();
catalog.initialize(
"nessie",
ImmutableMap.of(
CatalogProperties.WAREHOUSE_LOCATION,
temp.toUri().toString(),
CatalogProperties.URI,
uri,
NessieConfigConstants.CONF_NESSIE_CLIENT_NAME,
"Dummy"));
})
.isInstanceOf(RuntimeException.class)
.hasMessage("BUILD CALLED");
}

@Test
public void testAlternativeInitializeWithNulls() {
NessieCatalog catalog = new NessieCatalog();
Expand All @@ -128,41 +143,26 @@ public void testAlternativeInitializeWithNulls() {
}

@SuppressWarnings("rawtypes")
public static final class DummyClientBuilderImpl implements NessieClientBuilder {
public static final class DummyClientBuilderImpl extends AbstractNessieClientBuilder {

@SuppressWarnings("unused")
public static DummyClientBuilderImpl builder() {
return new DummyClientBuilderImpl();
}

@Override
public NessieClientBuilder fromSystemProperties() {
return this;
}

@Override
public NessieClientBuilder withAuthentication(NessieAuthentication authentication) {
return this;
}

@Override
public NessieClientBuilder withUri(URI uri) {
return this;
}

@Override
public NessieClientBuilder withAuthenticationFromConfig(Function configuration) {
return this;
public <A extends NessieApi> A build(Class<A> apiContract) {
throw new RuntimeException("BUILD CALLED");
}

@Override
public NessieClientBuilder fromConfig(Function configuration) {
return this;
public String name() {
return "Dummy";
}

@Override
public NessieApi build(Class apiContract) {
throw new RuntimeException("BUILD CALLED");
public int priority() {
return 42;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

org.apache.iceberg.nessie.TestCustomNessieClient$DummyClientBuilderImpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this one needed for the tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes