Skip to content

Commit

Permalink
[apache#5881] test(authorization): Support Hive test container with S…
Browse files Browse the repository at this point in the history
…QL based authorization (apache#5882)

### What changes were proposed in this pull request?

Support Hive test container with SQL based auhtorization 

### Why are the changes needed?

Fix: apache#5881 

### Does this PR introduce _any_ user-facing change?

Yes

### How was this patch tested?

Just a test code.
  • Loading branch information
jerqi authored Dec 18, 2024
1 parent e088c55 commit 92cf3c5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ allprojects {
param.environment("PROJECT_VERSION", project.version)

// Gravitino CI Docker image
param.environment("GRAVITINO_CI_HIVE_DOCKER_IMAGE", "apache/gravitino-ci:hive-0.1.16")
param.environment("GRAVITINO_CI_HIVE_DOCKER_IMAGE", "apache/gravitino-ci:hive-0.1.17")
param.environment("GRAVITINO_CI_KERBEROS_HIVE_DOCKER_IMAGE", "apache/gravitino-ci:kerberos-hive-0.1.5")
param.environment("GRAVITINO_CI_DORIS_DOCKER_IMAGE", "apache/gravitino-ci:doris-0.1.5")
param.environment("GRAVITINO_CI_TRINO_DOCKER_IMAGE", "apache/gravitino-ci:trino-0.1.6")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ContainerSuite implements Closeable {
private static volatile KafkaContainer kafkaContainer;
private static volatile DorisContainer dorisContainer;
private static volatile HiveContainer kerberosHiveContainer;
private static volatile HiveContainer sqlBaseHiveContainer;

private static volatile MySQLContainer mySQLContainer;
private static volatile MySQLContainer mySQLVersion5Container;
Expand Down Expand Up @@ -231,6 +232,34 @@ public void startKerberosHiveContainer() {
}
}

public void startSQLBaseAuthHiveContainer(Map<String, String> envVars) {
// If you want to enable SQL based authorization, you need both set the
// `ENABLE_SQL_BASE_AUTHORIZATION` environment.
if (envVars == null
|| (!Objects.equals(envVars.get(HiveContainer.HIVE_RUNTIME_VERSION), HiveContainer.HIVE3))
|| (!envVars.containsKey(HiveContainer.ENABLE_SQL_BASE_AUTHORIZATION))) {
throw new IllegalArgumentException(
"Error environment variables for Hive SQL base authorization container");
}

if (sqlBaseHiveContainer == null) {
synchronized (ContainerSuite.class) {
if (sqlBaseHiveContainer == null) {
initIfNecessary();
// Start Hive container
HiveContainer.Builder hiveBuilder =
HiveContainer.builder()
.withHostName("gravitino-ci-hive")
.withNetwork(network)
.withEnvVars(envVars);
HiveContainer container = closer.register(hiveBuilder.build());
container.start();
sqlBaseHiveContainer = container;
}
}
}
}

public void startTrinoContainer(
String trinoConfDir,
String trinoConnectorLibDir,
Expand Down Expand Up @@ -509,6 +538,10 @@ public HiveContainer getKerberosHiveContainer() {
return kerberosHiveContainer;
}

public HiveContainer getSQLBaseAuthHiveContainer() {
return sqlBaseHiveContainer;
}

public DorisContainer getDorisContainer() {
return dorisContainer;
}
Expand Down Expand Up @@ -673,6 +706,7 @@ public void close() throws IOException {
kafkaContainer = null;
dorisContainer = null;
kerberosHiveContainer = null;
sqlBaseHiveContainer = null;
pgContainerMap.clear();
} catch (Exception e) {
LOG.error("Failed to close ContainerEnvironment", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class HiveContainer extends BaseContainer {
public static final String HIVE_RUNTIME_VERSION = "HIVE_RUNTIME_VERSION";
public static final String HIVE2 = "hive2"; // The Hive container default version
public static final String HIVE3 = "hive3";
public static final String ENABLE_SQL_BASE_AUTHORIZATION = "ENABLE_SQL_BASE_AUTHORIZATION";
private static final int MYSQL_PORT = 3306;
public static final int HDFS_DEFAULTFS_PORT = 9000;
public static final int HIVE_METASTORE_PORT = 9083;
Expand Down

0 comments on commit 92cf3c5

Please sign in to comment.