Will-Lo commented on code in PR #3823:
URL: https://github.com/apache/gobblin/pull/3823#discussion_r1388702178


##########
gobblin-service/src/main/java/org/apache/gobblin/service/monitoring/DagActionStoreChangeMonitor.java:
##########
@@ -203,8 +203,8 @@ protected void submitFlowToDagManagerHelper(String 
flowGroup, String flowName, S
       URI flowUri = FlowSpec.Utils.createFlowSpecUri(flowId);
       spec = (FlowSpec) flowCatalog.getSpecs(flowUri);
       // Adds flowExecutionId to config to ensure they are consistent across 
hosts
-      FlowSpec updatedSpec = FlowSpec.Utils.createFlowSpecWithProperty(spec, 
ConfigurationKeys.FLOW_EXECUTION_ID_KEY, flowExecutionId);
-      this.orchestrator.submitFlowToDagManager(updatedSpec);
+      
spec.addPropertyToConfigAsProperties(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, 
flowExecutionId);

Review Comment:
   We need to be careful here for adhoc flows that already save a flow 
execution ID in the flowspec configs, for those do we know if the flow 
execution ID in their config is consistent if they don't have a trigger time, 
or should we check if the property already exists in properties to not override 
them?



##########
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:
   Is it possible to extend this test to also test for 
serialization/deserialization of the jobexecutionplan that is stored in the dag 
just because that was the area that caused the fatal issues



##########
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/FlowSpec.java:
##########
@@ -125,6 +125,18 @@ public static FlowSpec.Builder builder(URI catalogURI, 
Properties flowProps) {
       throw new RuntimeException("Unable to create a FlowSpec URI: " + e, e);
     }
   }
+
+  /**

Review Comment:
   I prefer if we name this function something more semantic, such as 
`addMutableProperty` and a reader for it as `getMutableProperty` so that the 
user will not attempt to read from this.confgs.



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