phet commented on code in PR #3948:
URL: https://github.com/apache/gobblin/pull/3948#discussion_r1594864769


##########
gobblin-service/src/test/java/org/apache/gobblin/service/modules/orchestration/proc/ReevaluateDagProcTest.java:
##########
@@ -61,18 +64,36 @@ public class ReevaluateDagProcTest {
   private final long flowExecutionId = System.currentTimeMillis();
   private final String flowGroup = "fg";
 
-  void mockDMSS(DagManagementStateStore dagManagementStateStore) throws 
IOException, SpecNotFoundException {
+  private ITestMetastoreDatabase testMetastoreDatabase;
+  private DagManagementStateStore dagManagementStateStore;
+
+  @BeforeClass
+  public void setUpClass() throws Exception {
+    this.testMetastoreDatabase = TestMetastoreDatabaseFactory.get();
+  }
+
+  @BeforeMethod
+  public void setUp() throws Exception {
+    this.dagManagementStateStore = 
spy(MostlyMySqlDagManagementStateStoreTest.getDummyDMSS(this.testMetastoreDatabase));
+    mockDMSSCommonBehavior(dagManagementStateStore);
+  }
+
+  private void mockDMSSCommonBehavior(DagManagementStateStore 
dagManagementStateStore) throws IOException, SpecNotFoundException {
     
doReturn(FlowSpec.builder().build()).when(dagManagementStateStore).getFlowSpec(any());
     doNothing().when(dagManagementStateStore).tryAcquireQuota(any());
     doNothing().when(dagManagementStateStore).addDagNodeState(any(), any());
+    doNothing().when(dagManagementStateStore).deleteDagNodeState(any(), any());
     doReturn(true).when(dagManagementStateStore).releaseQuota(any());
   }
 
+  @AfterClass(alwaysRun = true)
+  public void tearDownClass() throws Exception {
+    // `.close()` to avoid (in the aggregate, across multiple suites) - 
java.sql.SQLNonTransientConnectionException: Too many connections
+    this.testMetastoreDatabase.close();
+  }
+
   @Test
   public void testOneNextJobToRun() throws Exception {
-    ITestMetastoreDatabase testMetastoreDatabase = 
TestMetastoreDatabaseFactory.get();
-    DagManagementStateStore dagManagementStateStore = 
spy(MostlyMySqlDagManagementStateStoreTest.getDummyDMSS(testMetastoreDatabase));
-    mockDMSS(dagManagementStateStore);

Review Comment:
   while each test uses divergent mocking, they can still initialize the bulk 
of the spy setup in a `@BeforeMethod`, so resituated it there



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to