umustafi commented on code in PR #3823:
URL: https://github.com/apache/gobblin/pull/3823#discussion_r1391800736


##########
gobblin-service/src/test/java/org/apache/gobblin/service/modules/utils/FlowCompilationValidationHelperTest.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.service.modules.utils;
+
+import com.google.common.base.Optional;
+import java.io.IOException;
+import java.util.Properties;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.metrics.event.EventSubmitter;
+import org.apache.gobblin.runtime.api.FlowSpec;
+import 
org.apache.gobblin.service.modules.core.IdentityFlowToJobSpecCompilerTest;
+import org.apache.gobblin.service.modules.flow.IdentityFlowToJobSpecCompiler;
+import org.apache.gobblin.service.modules.flow.SpecCompiler;
+import org.apache.gobblin.service.modules.flowgraph.Dag;
+import org.apache.gobblin.service.modules.orchestration.UserQuotaManager;
+import org.apache.gobblin.service.modules.spec.JobExecutionPlan;
+import org.apache.gobblin.service.monitoring.FlowStatusGenerator;
+import org.apache.gobblin.util.ConfigUtils;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.*;
+
+
+/**
+ * Test functionality provided by the helper class re-used between the 
DagManager and Orchestrator for flow compilation.
+ */
+public class FlowCompilationValidationHelperTest {
+
+  class MockFlowCompilationValidationHelper extends 
FlowCompilationValidationHelper {
+
+    public MockFlowCompilationValidationHelper(SharedFlowMetricsSingleton 
sharedFlowMetricsSingleton,
+        SpecCompiler specCompiler, UserQuotaManager quotaManager, 
Optional<EventSubmitter> eventSubmitter,
+        FlowStatusGenerator flowStatusGenerator, boolean 
isFlowConcurrencyEnabled) {
+      super(sharedFlowMetricsSingleton, specCompiler, quotaManager, 
eventSubmitter, flowStatusGenerator,
+          isFlowConcurrencyEnabled);
+    }
+
+    /*
+      In overriden function simply return if concurrent execution is allowed 
or not because flowStatusGenerator will be
+      mocked
+     */
+    @Override
+    protected boolean isExecutionPermitted(FlowStatusGenerator 
flowStatusGenerator, String flowName, String flowGroup,
+        boolean allowConcurrentExecution) {
+      return allowConcurrentExecution;
+    }
+
+  }
+
+  /*
+  Creates a mock {@link FlowCompilationValidationHelper} which has a valid 
{@link SpecCompiler} but mocks other
+  components.
+   */
+  MockFlowCompilationValidationHelper 
createMockFlowCompilationValidationHelper(boolean isFlowConcurrencyEnabled) {
+    SpecCompiler specCompiler = new 
IdentityFlowToJobSpecCompiler(ConfigUtils.propertiesToConfig(new Properties()));
+    
specCompiler.onAddSpec(IdentityFlowToJobSpecCompilerTest.initTopologySpec());
+    return new 
MockFlowCompilationValidationHelper(mock(SharedFlowMetricsSingleton.class), 
specCompiler,
+        mock(UserQuotaManager.class), Optional.of(mock(EventSubmitter.class)), 
mock(FlowStatusGenerator.class),
+        isFlowConcurrencyEnabled);
+  }
+
+  /**
+   * Verifies that a flow spec that compiles to create a valid job execution 
plan dag will also generate one after
+   * having a flow execution id key-value pair added to its config
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  @Test
+  public void compileFlowSpec() throws IOException, InterruptedException {

Review Comment:
   I tried to extend this test for `serialization/deserialization` using the 
`convertDagIntoState / convertStateObjIntoDag` methods from 
`MysqlDagStateStore`, however right after compiling the FlowSpec is not ready 
for serialization/deserialization as there are more properties that are 
initialized and added to the `JobExecutionPlan dag` ie: `Future` and various 
URIs. I actually will remove the `FlowSpec` update completely to avoid these 
sort of issues. 



-- 
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