Skip to content

Commit

Permalink
Fix Tests, versions and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Oct 24, 2023
1 parent 64e7a0e commit c6283b9
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:9.2
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.2
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<app.main.class>com.dtsx.astra.cli.AstraCli</app.main.class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<astra-sdk.version>0.7.0</astra-sdk.version>
<astra-sdk.version>0.7.1</astra-sdk.version>
<jansi.version>2.4.1</jansi.version>
<airline.version>2.9.0</airline.version>
<slf4j.version>2.0.9</slf4j.version>
Expand Down
3 changes: 2 additions & 1 deletion src/main/dist/astra-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
autoload -U +X compinit > /dev/null 2>&1 && compinit
autoload -U +X bashcompinit > /dev/null 2>&1 && bashcompinit


# Generated by airline BashCompletionGenerator

containsElement () {
Expand Down Expand Up @@ -2353,7 +2354,7 @@ function _complete_astra_group_db_command_createcdc() {
echo ${COMPREPLY[@]}
return 0
;;
-p| --partition)
-p, --partition)
COMPREPLY=( $(compgen -W "${ARG_VALUES} ${ARG_GENERATED_VALUES}" -- ${CURR_WORD}) )
echo ${COMPREPLY[@]}
return 0
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/config/ConfigCreateCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
import com.dtsx.astra.cli.core.exception.TokenNotFoundException;
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.domain.Organization;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.github.rvesse.airline.annotations.Arguments;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void execute() {
throw new InvalidTokenException(token);
}
// validate token at the same time
Organization o = new AstraDevopsApiClient(token, env).getOrganization();
Organization o = new AstraOpsClient(token, env).getOrganization();
if (sectionName == null) {
sectionName = o.getName();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/dtsx/astra/cli/config/SetupCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.cli.core.out.LoggerShell;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;

Expand Down Expand Up @@ -53,7 +53,7 @@ public class SetupCmd extends AbstractCmd {
public void execute() {
if (tokenParam == null || tokenParam.isBlank()) {
verbose = true;
String token = null;
String token;
AstraCliConsole.banner();
boolean validToken = false;
Console cons;
Expand Down Expand Up @@ -98,7 +98,7 @@ private void createDefaultSection(String token)
try {
ConfigCreateCmd ccc = new ConfigCreateCmd();
ccc.token = removeQuotesIfAny(token);
ccc.sectionName = new AstraDevopsApiClient(token).getOrganization().getName();
ccc.sectionName = new AstraOpsClient(token).getOrganization().getName();
ccc.run();
} catch(Exception e) {
LoggerShell.warning("Invalid token: It must be start with 'AstraCS:..' and have Organization Administrator privileges.");
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/dtsx/astra/cli/core/CliContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.cli.core.out.LoggerShell;
import com.dtsx.astra.cli.core.out.OutputFormat;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.db.AstraDbClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
import com.dtsx.astra.sdk.org.domain.Organization;
import com.dtsx.astra.sdk.streaming.AstraStreamingClient;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
Expand Down Expand Up @@ -226,8 +226,8 @@ public AstraCliConfiguration getConfiguration() {
* @return
* current value of 'apiDevopsDatabases'
*/
public AstraDevopsApiClient getApiDevops() {
AstraDevopsApiClient devopsApiClient = new AstraDevopsApiClient(getToken(), getAstraEnvironment());
public AstraOpsClient getApiDevops() {
AstraOpsClient devopsApiClient = new AstraOpsClient(getToken(), getAstraEnvironment());
if (!getAstraEnvironment().equals(AstraEnvironment.PROD)) {
LoggerShell.info("You are using a non-production environment '%s' ".formatted(getAstraEnvironment()));
}
Expand All @@ -244,13 +244,13 @@ public AstraDevopsApiClient getApiDevops() {
* target environment
*/
public void validateCredentials(String token, AstraEnvironment env) {
validateDevopsClientConnection(new AstraDevopsApiClient(token, env));
validateDevopsClientConnection(new AstraOpsClient(token, env));
}

/**
* Validate that current Api Client is valid.
*/
private void validateDevopsClientConnection(AstraDevopsApiClient client) {
private void validateDevopsClientConnection(AstraOpsClient client) {
Organization org = client.getOrganization();
if (org.getId() == null) {
if (!client.getEnvironment().equals(AstraEnvironment.PROD)) {
Expand All @@ -267,7 +267,7 @@ private void validateDevopsClientConnection(AstraDevopsApiClient client) {
* @return
* current value of 'apiDevopsDatabases'
*/
public AstraDbClient getApiDevopsDatabases() {
public AstraDBOpsClient getApiDevopsDatabases() {
return getApiDevops().db();
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/dtsx/astra/cli/db/DaoDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.dtsx.astra.cli.db.exception.DatabaseNameNotUniqueException;
import com.dtsx.astra.cli.utils.AstraCliUtils;
import com.dtsx.astra.cli.utils.FileUtils;
import com.dtsx.astra.sdk.db.DatabaseClient;
import com.dtsx.astra.sdk.db.AstraDbClient;
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
import com.dtsx.astra.sdk.db.DbOpsClient;
import com.dtsx.astra.sdk.db.domain.Database;
import com.dtsx.astra.sdk.db.domain.Datacenter;
import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException;
Expand Down Expand Up @@ -103,8 +103,8 @@ public Database getDatabase(String databaseName)
* @throws DatabaseNotFoundException
* error when db does not exist
*/
public DatabaseClient getRequiredDatabaseClient(String databaseName) {
Optional<DatabaseClient> dbClient = getDatabaseClient(databaseName);
public DbOpsClient getRequiredDatabaseClient(String databaseName) {
Optional<DbOpsClient> dbClient = getDatabaseClient(databaseName);
if (dbClient.isPresent()) {
return dbClient.get();
}
Expand All @@ -121,15 +121,15 @@ public DatabaseClient getRequiredDatabaseClient(String databaseName) {
* @throws DatabaseNameNotUniqueException
* cli does not work if multiple db with same name
*/
public Optional<DatabaseClient> getDatabaseClient(String db)
public Optional<DbOpsClient> getDatabaseClient(String db)
throws DatabaseNameNotUniqueException {
AstraDbClient dbsClient = CliContext.getInstance().getApiDevopsDatabases();
AstraDBOpsClient dbsClient = CliContext.getInstance().getApiDevopsDatabases();

// Escape special chars
db = db.replace("\"", "");
// Database name containing spaces cannot be an id
if (!db.contains(" ") ) {
DatabaseClient dbClient = dbsClient.database(db);
DbOpsClient dbClient = dbsClient.database(db);
if (dbClient.exist()) {
LoggerShell.debug("Database found id=" + db);
return Optional.of(dbClient);
Expand Down Expand Up @@ -193,16 +193,16 @@ public void downloadCloudSecureBundle(String databaseName, String region, String
Datacenter dc = dcs.iterator().next();
if (dcs.size() > 1) {
if (null == region) {
throw new InvalidArgumentException(""
+ "Your database is deployed on multiple regions. "
throw new InvalidArgumentException(
"Your database is deployed on multiple regions. "
+ "A scb is associated to only one region. "
+ "Add -r or --region in the command to select one.");
}
Optional<Datacenter> optDc = dcs.stream()
.filter(d -> d.getName().equals(region)).findFirst();
if (optDc.isEmpty()) {
throw new InvalidArgumentException(""
+ "Your database is deployed on multiple regions. "
throw new InvalidArgumentException(
"Your database is deployed on multiple regions. "
+ "You select and invalid region name. "
+ "Please use one from %s".formatted(
dcs.stream().map(Datacenter::getName)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/dtsx/astra/cli/db/ServiceDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.dtsx.astra.cli.org.ServiceOrganization;
import com.dtsx.astra.cli.utils.AstraCliUtils;
import com.dtsx.astra.cli.utils.EnvFile;
import com.dtsx.astra.sdk.db.DatabaseClient;
import com.dtsx.astra.sdk.db.DbOpsClient;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
import com.dtsx.astra.sdk.db.domain.Database;
import com.dtsx.astra.sdk.db.domain.DatabaseCreationBuilder;
Expand Down Expand Up @@ -178,9 +178,9 @@ private ServiceDatabase() {
*/
public ExitCode waitForDbStatus(String databaseName, DatabaseStatusType status, int timeout)
throws DatabaseNameNotUniqueException, DatabaseNotFoundException {
Optional<DatabaseClient> dbClient = dbDao.getDatabaseClient(databaseName);
Optional<DbOpsClient> dbClient = dbDao.getDatabaseClient(databaseName);
if (dbClient.isPresent()) {
DatabaseClient dbc = dbClient.get();
DbOpsClient dbc = dbClient.get();
Optional<Database> optDb = dbc.find();
if (optDb.isPresent()) {
Database db = optDb.get();
Expand Down Expand Up @@ -271,7 +271,7 @@ public int retryUntilTimeoutOrSuccess(Database db, DatabaseStatusType status, in
*/
public int retryUntilDbDeleted(String dbName, int timeout) {
int retries = 0;
Optional<DatabaseClient> optDbClient = dbDao.getDatabaseClient(dbName);
Optional<DbOpsClient> optDbClient = dbDao.getDatabaseClient(dbName);
while (retries++ < timeout && optDbClient.isPresent()) {
try {
Thread.sleep(1000);
Expand Down Expand Up @@ -355,7 +355,7 @@ public void createDb(String databaseName, String databaseRegion, String keyspace

// if multiple databases with same name => error
try {
Optional<DatabaseClient> dbClient = dbDao.getDatabaseClient(databaseName);
Optional<DbOpsClient> dbClient = dbDao.getDatabaseClient(databaseName);
if (dbClient.isEmpty()) {
createNewDb(databaseName, databaseRegion, keyspaceName, vectorSearch);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/db/cdc/ServiceCdc.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.dtsx.astra.cli.core.out.StringBuilderAnsi;
import com.dtsx.astra.cli.db.DaoDatabase;
import com.dtsx.astra.cli.db.exception.DatabaseNameNotUniqueException;
import com.dtsx.astra.sdk.db.AstraDbClient;
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
import com.dtsx.astra.sdk.db.domain.Database;
import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException;
import com.dtsx.astra.sdk.streaming.domain.CdcDefinition;
Expand Down Expand Up @@ -105,7 +105,7 @@ private ServiceCdc() {
* @return
* api devops
*/
private AstraDbClient apiDevopsDb() {
private AstraDBOpsClient apiDevopsDb() {
return CliContext.getInstance().getApiDevopsDatabases();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/db/region/ServiceRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.dtsx.astra.cli.core.out.ShellTable;
import com.dtsx.astra.cli.db.DaoDatabase;
import com.dtsx.astra.cli.db.exception.InvalidDatabaseStateException;
import com.dtsx.astra.sdk.db.AstraDbClient;
import com.dtsx.astra.sdk.db.AstraDBOpsClient;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
import com.dtsx.astra.sdk.db.domain.Database;
import com.dtsx.astra.sdk.db.domain.DatabaseStatusType;
Expand Down Expand Up @@ -97,7 +97,7 @@ private ServiceRegion() {
* @return
* api devops
*/
private AstraDbClient apiDevopsDb() {
private AstraDBOpsClient apiDevopsDb() {
return CliContext.getInstance().getApiDevopsDatabases();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/iam/role/ServiceRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.dtsx.astra.cli.core.out.JsonOutput;
import com.dtsx.astra.cli.core.out.ShellTable;
import com.dtsx.astra.cli.iam.role.exception.RoleNotFoundException;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.domain.Role;
import com.dtsx.astra.sdk.utils.IdUtils;

Expand Down Expand Up @@ -79,7 +79,7 @@ private ServiceRole() {
* @return
* api devops
*/
private AstraDevopsApiClient apiDevopsOrg() {
private AstraOpsClient apiDevopsOrg() {
return CliContext.getInstance().getApiDevops();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/iam/token/ServiceToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.dtsx.astra.cli.core.out.ShellTable;
import com.dtsx.astra.cli.iam.role.AstraToken;
import com.dtsx.astra.cli.iam.role.ServiceRole;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.TokensClient;
import com.dtsx.astra.sdk.org.domain.CreateTokenResponse;
import com.dtsx.astra.sdk.org.domain.IamToken;
Expand Down Expand Up @@ -91,7 +91,7 @@ public static synchronized ServiceToken getInstance() {
* @return
* api devops
*/
private AstraDevopsApiClient apiDevopsOrg() {
private AstraOpsClient apiDevopsOrg() {
return CliContext.getInstance().getApiDevops();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/iam/user/ServiceUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.dtsx.astra.cli.iam.role.exception.RoleNotFoundException;
import com.dtsx.astra.cli.iam.user.exception.UserAlreadyExistException;
import com.dtsx.astra.cli.iam.user.exception.UserNotFoundException;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.domain.Role;
import com.dtsx.astra.sdk.org.domain.User;
import com.dtsx.astra.sdk.utils.IdUtils;
Expand Down Expand Up @@ -82,7 +82,7 @@ private ServiceUser() {}
* @return
* api devops
*/
private AstraDevopsApiClient apiDevopsOrg() {
private AstraOpsClient apiDevopsOrg() {
return CliContext.getInstance().getApiDevops();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dtsx/astra/cli/org/ServiceOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.dtsx.astra.cli.core.CliContext;
import com.dtsx.astra.cli.core.out.AstraCliConsole;
import com.dtsx.astra.cli.core.out.ShellTable;
import com.dtsx.astra.sdk.AstraDevopsApiClient;
import com.dtsx.astra.sdk.AstraOpsClient;
import com.dtsx.astra.sdk.org.domain.Organization;

import java.util.ArrayList;
Expand Down Expand Up @@ -83,7 +83,7 @@ public static synchronized ServiceOrganization getInstance() {
* @return
* api devops
*/
private AstraDevopsApiClient apiDevopsOrg() {
private AstraOpsClient apiDevopsOrg() {
return CliContext.getInstance().getApiDevops();
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/native-image/reflect-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@
{"name":"getCloudRegion","parameterTypes":[] },
{"name":"getPlan","parameterTypes":[] },
{"name":"getTenantName","parameterTypes":[] },
{"name":"getUserEmail","parameterTypes":[] }
{"name":"getUserEmail", "parameterTypes":[] },
{"name":"getClusterName", "parameterTypes":[] }
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ void should_not_create_config() {
assertExitCodeCli(ExitCode.CONFIGURATION, "config create demo");
assertExitCodeCli(ExitCode.CONFIGURATION, "config create demo -t invalid");
}

}
17 changes: 8 additions & 9 deletions src/test/java/com/dtsx/astra/cli/test/db/DbCdcCommandsTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.dtsx.astra.cli.test.db;

import java.util.Optional;
import java.util.UUID;

import com.dtsx.astra.cli.core.ExitCode;
import com.dtsx.astra.cli.test.AbstractCmdTest;
import com.dtsx.astra.sdk.db.DbOpsClient;
import com.dtsx.astra.sdk.streaming.TenantClient;
import com.dtsx.astra.sdk.streaming.domain.CdcDefinition;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -11,11 +13,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import com.dtsx.astra.cli.core.ExitCode;
import com.dtsx.astra.cli.test.AbstractCmdTest;
import com.dtsx.astra.sdk.db.DatabaseClient;
import com.dtsx.astra.sdk.streaming.TenantClient;
import com.dtsx.astra.sdk.streaming.domain.CdcDefinition;
import java.util.Optional;
import java.util.UUID;

/**
* Test commands relative to CDC.
Expand All @@ -27,7 +26,7 @@ class DbCdcCommandsTest extends AbstractCmdTest {
.toString().replaceAll("-", "")
.substring(0, 12);

static DatabaseClient dbClient;
static DbOpsClient dbClient;
static TenantClient tenantClient;

@BeforeAll
Expand Down
Loading

0 comments on commit c6283b9

Please sign in to comment.