DBZ-7221 sharded mongo tests - fixed deployments when internal auth isn't used, removed unnecessary permissions for debezium user

This commit is contained in:
Martin Medek 2024-02-12 15:58:26 +01:00 committed by Ondrej Babec
parent 26004d67a5
commit ec90242567
8 changed files with 7 additions and 12 deletions

View File

@ -109,7 +109,7 @@
<database.mongo.docker.replica.size>1</database.mongo.docker.replica.size> <database.mongo.docker.replica.size>1</database.mongo.docker.replica.size>
<!--Mongodb sharded configuration--> <!--Mongodb sharded configuration-->
<database.mongo.sharded.enable.internal.auth>true</database.mongo.sharded.enable.internal.auth> <database.mongo.use.keyfile>true</database.mongo.use.keyfile>
<!--DB2 configuration --> <!--DB2 configuration -->
@ -561,7 +561,7 @@
<test.database.mongo.docker.replica.size>${database.mongo.docker.replica.size}</test.database.mongo.docker.replica.size> <test.database.mongo.docker.replica.size>${database.mongo.docker.replica.size}</test.database.mongo.docker.replica.size>
<!--Mongo sharded configuration--> <!--Mongo sharded configuration-->
<test.database.mongo.sharded.enable.internal.auth>${database.mongo.sharded.enable.internal.auth}</test.database.mongo.sharded.enable.internal.auth> <test.database.mongo.use.keyfile>${database.mongo.use.keyfile}</test.database.mongo.use.keyfile>
<!--DB2 configuration--> <!--DB2 configuration-->
<test.database.db2.host>${database.db2.host}</test.database.db2.host> <test.database.db2.host>${database.db2.host}</test.database.db2.host>

View File

@ -101,7 +101,7 @@ private ConfigProperties() {
public static final String DATABASE_MONGO_DBZ_LOGIN_DBNAME = System.getProperty("test.database.mongo.dbz.login.dbname", "admin"); public static final String DATABASE_MONGO_DBZ_LOGIN_DBNAME = System.getProperty("test.database.mongo.dbz.login.dbname", "admin");
public static final Optional<String> DATABASE_MONGO_HOST = stringOptionalProperty("test.database.mongo.host"); public static final Optional<String> DATABASE_MONGO_HOST = stringOptionalProperty("test.database.mongo.host");
public static final int DATABASE_MONGO_PORT = Integer.parseInt(System.getProperty("test.database.mongo.port", "27017")); public static final int DATABASE_MONGO_PORT = Integer.parseInt(System.getProperty("test.database.mongo.port", "27017"));
public static final boolean DATABASE_MONGO_ENABLE_INTERNAL_AUTH = Boolean.parseBoolean(System.getProperty("test.database.mongo.sharded.enable.internal.auth")); public static final boolean DATABASE_MONGO_USE_KEYFILE = Boolean.parseBoolean(System.getProperty("test.database.mongo.use.keyfile"));
public static final String DATABASE_MONGO_DOCKER_DESKTOP_PORTS = System.getProperty("database.mongo.docker.desktop.ports", "27017:27117"); public static final String DATABASE_MONGO_DOCKER_DESKTOP_PORTS = System.getProperty("database.mongo.docker.desktop.ports", "27017:27117");
public static final int DATABASE_MONGO_DOCKER_REPLICA_SIZE = Integer.parseInt(System.getProperty("database.mongo.docker.replica.size", "1")); public static final int DATABASE_MONGO_DOCKER_REPLICA_SIZE = Integer.parseInt(System.getProperty("database.mongo.docker.replica.size", "1"));

View File

@ -41,8 +41,6 @@ public void start() {
@Override @Override
public void stop() { public void stop() {
ocpUtils.scaleDeploymentToZero(deployment); ocpUtils.scaleDeploymentToZero(deployment);
// ocp.apps().deployments().inNamespace(project).delete(deployment);
// ocp.services().inNamespace(project).delete(service);
} }
public void waitForStopped() { public void waitForStopped() {

View File

@ -83,7 +83,6 @@ public static Deployment configServerDeployment(int num) {
.withImage(ConfigProperties.DOCKER_IMAGE_MONGO_SHARDED) .withImage(ConfigProperties.DOCKER_IMAGE_MONGO_SHARDED)
.withCommand("mongod", .withCommand("mongod",
"--configsvr", "--configsvr",
"--auth",
"--replSet", "--replSet",
OcpMongoShardedConstants.MONGO_CONFIG_REPLICASET_NAME, OcpMongoShardedConstants.MONGO_CONFIG_REPLICASET_NAME,
"--dbpath", "--dbpath",

View File

@ -82,7 +82,6 @@ public static Deployment shardDeployment(int shardNum, int replicaNum) {
.withImage(ConfigProperties.DOCKER_IMAGE_MONGO_SHARDED) .withImage(ConfigProperties.DOCKER_IMAGE_MONGO_SHARDED)
.withCommand("mongod", .withCommand("mongod",
"--shardsvr", "--shardsvr",
"--auth",
"--replSet", "--replSet",
getShardReplicaSetName(shardNum), getShardReplicaSetName(shardNum),
"--dbpath", "--dbpath",

View File

@ -35,7 +35,7 @@ protected OcpMongoShardedController databaseController() throws Exception {
.withShardCount(OcpMongoShardedConstants.SHARD_COUNT) .withShardCount(OcpMongoShardedConstants.SHARD_COUNT)
.withReplicaCount(OcpMongoShardedConstants.REPLICAS_IN_SHARD) .withReplicaCount(OcpMongoShardedConstants.REPLICAS_IN_SHARD)
.withShardKeys(getTestShardKeys()) .withShardKeys(getTestShardKeys())
.withUseInternalAuth(ConfigProperties.DATABASE_MONGO_ENABLE_INTERNAL_AUTH) .withUseInternalAuth(ConfigProperties.DATABASE_MONGO_USE_KEYFILE)
.withRootUser(ConfigProperties.DATABASE_MONGO_USERNAME, ConfigProperties.DATABASE_MONGO_SA_PASSWORD) .withRootUser(ConfigProperties.DATABASE_MONGO_USERNAME, ConfigProperties.DATABASE_MONGO_SA_PASSWORD)
.build(); .build();
controller = deployer.deploy(); controller = deployer.deploy();

View File

@ -23,8 +23,7 @@ db.createUser({
{ role: "listDatabases", db: "admin" }, { role: "listDatabases", db: "admin" },
{ role: "readChangeStream", db: "admin" }, { role: "readChangeStream", db: "admin" },
{ role: "readAnyDatabase", db: "admin" }, { role: "readAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }, { role: "read", db: "config", collection: "shards" },
{ role: "read", db: "config" }, { role: "read", db: "local"}
{role: "read", db: "local"}
] ]
}); });

View File

@ -3,7 +3,7 @@ rs.initiate({ _id: "${rsId}", configsvr: ${configServer?c}, members: [${members}
let isPrimary = false; let isPrimary = false;
let count = 0; let count = 0;
// wait for primary node election // wait for primary node election
while(isPrimary == false && count < 30) { while(isPrimary == false && count < 60) {
const rplStatus = db.adminCommand({ replSetGetStatus : 1 }); const rplStatus = db.adminCommand({ replSetGetStatus : 1 });
isPrimary = rplStatus.members[0].stateStr === "PRIMARY"; isPrimary = rplStatus.members[0].stateStr === "PRIMARY";
print("is primary result: ", isPrimary); print("is primary result: ", isPrimary);