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

Add test for AccumuloConfig #20831

Merged
merged 2 commits into from
Feb 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public String getZkMetadataRoot()

@Config(ZOOKEEPER_METADATA_ROOT)
@ConfigDescription("Sets the root znode for metadata storage")
public void setZkMetadataRoot(String zkMetadataRoot)
public AccumuloConfig setZkMetadataRoot(String zkMetadataRoot)
{
this.zkMetadataRoot = zkMetadataRoot;
return this;
}

@NotNull
Expand All @@ -122,9 +123,10 @@ public int getCardinalityCacheSize()

@Config(CARDINALITY_CACHE_SIZE)
@ConfigDescription("Sets the cardinality cache size")
public void setCardinalityCacheSize(int cardinalityCacheSize)
public AccumuloConfig setCardinalityCacheSize(int cardinalityCacheSize)
{
this.cardinalityCacheSize = cardinalityCacheSize;
return this;
}

@NotNull
Expand All @@ -135,8 +137,9 @@ public Duration getCardinalityCacheExpiration()

@Config(CARDINALITY_CACHE_EXPIRE_DURATION)
@ConfigDescription("Sets the cardinality cache expiration")
public void setCardinalityCacheExpiration(Duration cardinalityCacheExpiration)
public AccumuloConfig setCardinalityCacheExpiration(Duration cardinalityCacheExpiration)
{
this.cardinalityCacheExpiration = cardinalityCacheExpiration;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Licensed 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.
*/
package io.trino.plugin.accumulo.conf;

import com.google.common.collect.ImmutableMap;
import io.airlift.units.Duration;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults;
import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MINUTES;

class TestAccumuloConfig
{
@Test
void testDefaults()
{
assertRecordedDefaults(recordDefaults(AccumuloConfig.class)
.setInstance(null)
.setZooKeepers(null)
.setUsername(null)
.setPassword(null)
.setZkMetadataRoot("/trino-accumulo")
.setCardinalityCacheSize(100_000)
.setCardinalityCacheExpiration(new Duration(5, MINUTES)));
}

@Test
void testExplicitPropertyMappings()
{
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put("accumulo.instance", "accumulo")
.put("accumulo.zookeepers", "zookeeper.example.com:2181")
.put("accumulo.username", "user")
.put("accumulo.password", "password")
.put("accumulo.zookeeper.metadata.root", "/trino-accumulo-metadata")
.put("accumulo.cardinality.cache.size", "999")
.put("accumulo.cardinality.cache.expire.duration", "1h")
.buildOrThrow();

AccumuloConfig expected = new AccumuloConfig()
.setInstance("accumulo")
.setZooKeepers("zookeeper.example.com:2181")
.setUsername("user")
.setPassword("password")
.setZkMetadataRoot("/trino-accumulo-metadata")
.setCardinalityCacheSize(999)
.setCardinalityCacheExpiration(new Duration(1, HOURS));

assertFullMapping(properties, expected);
}
}
Loading