Skip to content

Commit

Permalink
[MINOR] test: fix NPE for test PartitionBalanceAssignmentStrategyTest (
Browse files Browse the repository at this point in the history
…#2322)

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

Fix NPE for test PartitionBalanceAssignmentStrategyTest 

### Why are the changes needed?

It will NPE if The metrics have not register to MetricsSystem yet for UTs.

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

No.

### How was this patch tested?

Existing UT.
  • Loading branch information
maobaolong authored Jan 6, 2025
1 parent 3b0521a commit 66c3f3c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.hadoop.conf.Configuration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.apache.uniffle.common.PartitionRange;
import org.apache.uniffle.coordinator.CoordinatorConf;
import org.apache.uniffle.coordinator.ServerNode;
import org.apache.uniffle.coordinator.SimpleClusterManager;
import org.apache.uniffle.coordinator.metric.CoordinatorMetrics;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -45,6 +48,16 @@ public class BasicAssignmentStrategyTest {
Set<String> tags = Sets.newHashSet("test");
private int shuffleNodesMax = 7;

@BeforeEach
public void setUp() {
CoordinatorMetrics.register();
}

@AfterEach
public void clear() {
CoordinatorMetrics.clear();
}

@Test
public void testAssign() throws Exception {
CoordinatorConf ssc = new CoordinatorConf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.hadoop.conf.Configuration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.apache.uniffle.coordinator.CoordinatorConf;
import org.apache.uniffle.coordinator.ServerNode;
import org.apache.uniffle.coordinator.SimpleClusterManager;
import org.apache.uniffle.coordinator.metric.CoordinatorMetrics;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand All @@ -46,6 +49,16 @@ public class PartitionBalanceAssignmentStrategyTest {
private int shuffleNodesMax = 5;
private Set<String> tags = Sets.newHashSet("test");

@BeforeEach
public void setUp() {
CoordinatorMetrics.register();
}

@AfterEach
public void clear() {
CoordinatorMetrics.clear();
}

@Test
public void testAssign() throws Exception {
CoordinatorConf ssc = new CoordinatorConf();
Expand Down

0 comments on commit 66c3f3c

Please sign in to comment.