Skip to content

Commit

Permalink
[#23071] yugabyted: Add tests for yugabyted cluster creation.
Browse files Browse the repository at this point in the history
Summary:
The initial framework for Yugabyted testing has been expanded to include several new test cases.

Added Tests:

  1. TestYugabytedSingleNode.java - Validates single node setups.

  2. TestYugabytedMultiZone.java - Tests multi-zone configurations.

  3. TestYugabytedMultiRegion.java - Tests multi-region deployments.

  4. TestYugabytedStopandDestroy.java - Tests stop and destroy operations.

  5. TestYugabytedEAR.java - Tests EAR (Encryption at Rest) configurations and deployments.

  6. TestYugabytedDemo.java - Validates the demo command.

  7.  TestYugabytedCollectLogs.java - Tests log collection.

  8. TestYugabytedPgParity.java - Ensures PostgreSQL parity by checking specific configurations.

  9. TestYugabytedPITR.java - Tests Point-In-Time Recovery (PITR) commands.

  10. TestYugabytedConnMgr.java - Tests the connection manager functionality.

  11. TestYugabytedLeaderPinning.java - Tests leader pinning functionality.
Jira: DB-12006

Test Plan: ./yb_build.sh --java-test 'org.yb.yugabyted.*'

Reviewers: nikhil, sgarg-yb

Reviewed By: nikhil

Subscribers: shikhar.sahay

Differential Revision: https://phorge.dev.yugabyte.com/D36314
  • Loading branch information
ShikharSahay committed Jul 12, 2024
1 parent c319a56 commit 26eaeaa
Show file tree
Hide file tree
Showing 21 changed files with 2,120 additions and 132 deletions.
29 changes: 29 additions & 0 deletions bin/yugabyted
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,37 @@ def check_files_in_path(path, files):

return not has_error

def get_ysqlsh_test_env_path():

# Find directories inside YUGABYTE_DIR containing ysqlsh
directories_with_ysqlsh = find_directories_with_ysqlsh(YUGABYTE_DIR)
if directories_with_ysqlsh:
for directory in directories_with_ysqlsh:
if 'postgres/bin' in directory:
ysqlsh_path = os.path.join(directory, 'ysqlsh')
Output.log("Using directory for running ysqlsh: {}".format(
directory))
return ysqlsh_path
else:
Output.log_error_and_exit(
"No directories containing ysqlsh were found.")


def find_directories_with_ysqlsh(root_dir):
directories_with_ysqlsh = []
for dirpath, _, filenames in os.walk(root_dir):
if 'ysqlsh' in filenames:
directories_with_ysqlsh.append(dirpath)
return directories_with_ysqlsh

# Finds the path of a particular YB binary
def find_binary_location(binary_name):

# Specific path for ysqlsh in test environment
is_test_env = os.getenv('USER') == 'jenkins'
if binary_name == "ysqlsh" and is_test_env:
return get_ysqlsh_test_env_path()

# Default if tar is downloaded
dir_candidates = [
os.path.join(YUGABYTE_DIR, "bin")
Expand Down
6 changes: 6 additions & 0 deletions java/yb-yugabyted/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class BaseMiniYugabytedClusterTest extends BaseYBTest {
*/
protected static MiniYugabytedCluster miniYugabytedCluster;

protected static MiniYugabytedClusterParameters clusterParameters;

protected static List<MiniYugabytedNodeConfigurations> clusterConfigurations;

/**
* Comma separate describing the master addresses and ports.
*/
Expand Down Expand Up @@ -60,7 +64,7 @@ public void setUpBefore() throws Exception {
clusterNeedsRecreation = false;
}
if (miniYugabytedCluster == null) {
createMiniCluster(1);
createMiniCluster(clusterParameters.numNodes);
} else if (shouldRestartMiniClusterBetweenTests()) {
LOG.info("Restarting the MiniCluster");
miniYugabytedCluster.restart();
Expand All @@ -79,18 +83,16 @@ protected final void createMiniYugabytedCluster(int numNodes) throws Exception {

final int replicationFactor = getReplicationFactor();

MiniYugabytedClusterParameters clusterParameters = new MiniYugabytedClusterParameters();

// miniYugabytedCluster = new MiniYugabytedCluster(clusterParameters,
// getMasterFlags(), getMasterFlags(), getTServerFlags(),
// null, getMasterFlags(), clientHost, certFile,
// clientCertFile, clientKeyFile);

// TO-DO: replace all nulls with the actual fields.
miniYugabytedCluster = new MiniYugabytedCluster(clusterParameters,
null, null, null,
null, null, null, null,
null, null, null);
miniYugabytedCluster = new MiniYugabytedCluster(
clusterParameters,
clusterConfigurations
);

masterAddresses = miniYugabytedCluster.getMasterAddresses();
masterHostPorts = miniYugabytedCluster.getMasterHostPorts();
Expand Down
Loading

0 comments on commit 26eaeaa

Please sign in to comment.