Skip to content

Commit

Permalink
[MINOR] Correct order of test services start in UtilitiesTestBase (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
geserdugarov authored Jun 4, 2024
1 parent 06457c0 commit 9246fd7
Showing 1 changed file with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public static void initTestServices() throws Exception {

public static void initTestServices(boolean needsHdfs, boolean needsHive, boolean needsZookeeper) throws Exception {
hadoopConf = HoodieTestUtils.getDefaultStorageConf().unwrap();

if (needsZookeeper) {
zookeeperTestService = new ZookeeperTestService(hadoopConf);
zookeeperTestService.start();
}

if (needsHdfs) {
hdfsTestService = new HdfsTestService(hadoopConf);
dfsCluster = hdfsTestService.start(true);
Expand All @@ -160,11 +166,6 @@ public static void initTestServices(boolean needsHdfs, boolean needsHive, boolea
clearHiveDb(basePath + "/dummy" + System.currentTimeMillis());
}

if (needsZookeeper) {
zookeeperTestService = new ZookeeperTestService(hadoopConf);
zookeeperTestService.start();
}

jsc = UtilHelpers.buildSparkContext(UtilitiesTestBase.class.getName() + "-hoodie", "local[4]", sparkConf());
context = new HoodieSparkEngineContext(jsc);
sqlContext = new SQLContext(jsc);
Expand All @@ -175,24 +176,27 @@ public static void initTestServices(boolean needsHdfs, boolean needsHive, boolea
public static void cleanUpUtilitiesTestServices() {
List<String> failedReleases = new ArrayList<>();
try {
if (fs != null) {
fs.delete(new Path(basePath), true);
fs.close();
fs = null;
if (sparkSession != null) {
sparkSession.close();
sparkSession = null;
}
} catch (IOException ie) {
ie.printStackTrace();
failedReleases.add("FileSystem");
} catch (Exception e) {
e.printStackTrace();
failedReleases.add("SparkSession");
}

if (context != null) {
context = null;
}

try {
if (hdfsTestService != null) {
hdfsTestService.stop();
hdfsTestService = null;
if (jsc != null) {
jsc.stop();
jsc = null;
}
} catch (Exception e) {
e.printStackTrace();
failedReleases.add("HdfsTestService");
failedReleases.add("JSC");
}

try {
Expand All @@ -216,37 +220,34 @@ public static void cleanUpUtilitiesTestServices() {
}

try {
if (zookeeperTestService != null) {
zookeeperTestService.stop();
zookeeperTestService = null;
if (fs != null) {
fs.delete(new Path(basePath), true);
fs.close();
fs = null;
}
} catch (Exception e) {
e.printStackTrace();
failedReleases.add("ZooKeeperTestService");
} catch (IOException ie) {
ie.printStackTrace();
failedReleases.add("FileSystem");
}

try {
if (jsc != null) {
jsc.stop();
jsc = null;
if (hdfsTestService != null) {
hdfsTestService.stop();
hdfsTestService = null;
}
} catch (Exception e) {
e.printStackTrace();
failedReleases.add("JSC");
failedReleases.add("HdfsTestService");
}

try {
if (sparkSession != null) {
sparkSession.close();
sparkSession = null;
if (zookeeperTestService != null) {
zookeeperTestService.stop();
zookeeperTestService = null;
}
} catch (Exception e) {
e.printStackTrace();
failedReleases.add("SparkSession");
}

if (context != null) {
context = null;
failedReleases.add("ZooKeeperTestService");
}

if (!failedReleases.isEmpty()) {
Expand Down

0 comments on commit 9246fd7

Please sign in to comment.