diff --git a/core/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java b/core/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java index e3c695f..c557098 100644 --- a/core/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java +++ b/core/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java @@ -18,9 +18,11 @@ public class Database { public static final String DEFAULT_NAME = "redis-enterprise-admin-db"; - public static final long MB_TO_BYTES = 1024 ^ 2; + public static final long KILO = 1024; + public static final long MEGA = KILO * KILO; + public static final long GIGA = MEGA * KILO; public static final long DEFAULT_MEMORY_MB = 100; - public static final long DEFAULT_MEMORY = DEFAULT_MEMORY_MB * MB_TO_BYTES; + public static final long DEFAULT_MEMORY = DEFAULT_MEMORY_MB * MEGA; public static final int DEFAULT_CLUSTER_SHARD_COUNT = 3; public static List defaultShardKeyRegexes() { @@ -348,8 +350,16 @@ public Builder memory(long memory) { return this; } + public Builder memoryKB(long memory) { + return memory(memory * KILO); + } + public Builder memoryMB(long memory) { - return memory(memory * MB_TO_BYTES); + return memory(memory * MEGA); + } + + public Builder memoryGB(long memory) { + return memory(memory * GIGA); } public Builder port(Integer port) { diff --git a/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/AbstractAdminTests.java b/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/AbstractAdminTests.java index a372d37..fe7b54b 100644 --- a/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/AbstractAdminTests.java +++ b/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/AbstractAdminTests.java @@ -89,8 +89,9 @@ void deleteDatabase() throws ParseException, GeneralSecurityException, IOExcepti @Test void createDatabaseException() throws ParseException, IOException { - Assertions.assertThrows(HttpResponseException.class, () -> admin.createDatabase(Database.builder() - .name("DatabaseCreateExceptionTestDB").memory(999000 * Database.MB_TO_BYTES).build())); + long memory = 999 * Database.GIGA; + Assertions.assertThrows(HttpResponseException.class, () -> admin + .createDatabase(Database.builder().name("DatabaseCreateExceptionTestDB").memory(memory).build())); } } diff --git a/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/ServerAdminTests.java b/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/ServerAdminTests.java index da7cbc6..5b89e73 100644 --- a/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/ServerAdminTests.java +++ b/core/redis-enterprise-admin/src/test/java/com/redis/enterprise/ServerAdminTests.java @@ -1,15 +1,16 @@ package com.redis.enterprise; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -@Disabled // @EnabledIfEnvironmentVariable(named = RedisEnterpriseServer.ENV_HOST, matches - // = ".*") +import com.redis.testcontainers.RedisEnterpriseServer; + +@EnabledIfEnvironmentVariable(named = RedisEnterpriseServer.ENV_HOST, matches = ".*") class ServerAdminTests extends AbstractAdminTests { @Override protected Admin admin() { Admin admin = new Admin(); - // TODO admin.withHost(System.getenv(RedisEnterpriseServer.ENV_HOST)); + admin.withHost(System.getenv(RedisEnterpriseServer.ENV_HOST)); return admin; }