[ 
https://issues.apache.org/jira/browse/GOBBLIN-1764?focusedWorklogId=839788&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839788
 ]

ASF GitHub Bot logged work on GOBBLIN-1764:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Jan/23 00:21
            Start Date: 18/Jan/23 00:21
    Worklog Time Spent: 10m 
      Work Description: Will-Lo commented on code in PR #3623:
URL: https://github.com/apache/gobblin/pull/3623#discussion_r1072965455


##########
gobblin-service/src/test/java/org/apache/gobblin/service/monitoring/GaaSObservabilityProducerTest.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.monitoring;
+
+import java.time.ZonedDateTime;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Queue;
+
+import org.junit.Test;
+import org.testng.Assert;
+
+import com.google.common.collect.Maps;
+
+import org.apache.gobblin.configuration.State;
+import org.apache.gobblin.metrics.GaaSObservabilityEventExperimental;
+import org.apache.gobblin.metrics.JobStatus;
+import org.apache.gobblin.metrics.event.TimingEvent;
+import 
org.apache.gobblin.runtime.troubleshooter.InMemoryMultiContextIssueRepository;
+import org.apache.gobblin.runtime.troubleshooter.Issue;
+import org.apache.gobblin.runtime.troubleshooter.IssueSeverity;
+import org.apache.gobblin.runtime.troubleshooter.MultiContextIssueRepository;
+import org.apache.gobblin.runtime.troubleshooter.TroubleshooterUtils;
+import org.apache.gobblin.service.ExecutionStatus;
+
+
+public class GaaSObservabilityProducerTest {
+
+  private MultiContextIssueRepository issueRepository = new 
InMemoryMultiContextIssueRepository();
+  Queue<GaaSObservabilityEventExperimental> emittedEvents = new LinkedList<>();
+
+  @Test
+  public void testCreateGaaSObservabilityEvent() throws Exception {
+    String flowGroup = "testFlowGroup1";
+    String flowName = "testFlowName1";
+    String jobName = String.format("%s_%s_%s", flowGroup, flowName, 
"testJobName1");
+    String flowExecutionId = "1";
+    this.issueRepository.put(
+        TroubleshooterUtils.getContextIdForJob(flowGroup, flowName, 
flowExecutionId, jobName),
+        createTestIssue("issueSummary", "issueCode", IssueSeverity.INFO)
+    );
+    GaaSObservabilityEventProducer producer = new 
MockGaaSObservabilityProducer(new State(), this.issueRepository);
+    Map<String, String> gteEventMetadata = Maps.newHashMap();
+    gteEventMetadata.put(TimingEvent.FlowEventConstants.FLOW_GROUP_FIELD, 
flowGroup);
+    gteEventMetadata.put(TimingEvent.FlowEventConstants.FLOW_NAME_FIELD, 
flowName);
+    
gteEventMetadata.put(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD, 
"1");
+    gteEventMetadata.put(TimingEvent.FlowEventConstants.JOB_NAME_FIELD, 
jobName);
+    gteEventMetadata.put(TimingEvent.FlowEventConstants.JOB_GROUP_FIELD, 
flowName);
+    gteEventMetadata.put(TimingEvent.METADATA_MESSAGE, "hostName");
+    gteEventMetadata.put(TimingEvent.METADATA_START_TIME, "1");
+    gteEventMetadata.put(TimingEvent.METADATA_END_TIME, "100");
+    gteEventMetadata.put(JobStatusRetriever.EVENT_NAME_FIELD, 
ExecutionStatus.COMPLETE.name());
+
+    Properties jobStatusProps = new Properties();
+    jobStatusProps.putAll(gteEventMetadata);
+    producer.emitObservabilityEvent(new State(jobStatusProps));
+
+    Assert.assertEquals(emittedEvents.size(), 1);
+    GaaSObservabilityEventExperimental event = emittedEvents.poll();
+    Assert.assertEquals(event.getFlowGroup(), flowGroup);
+    Assert.assertEquals(event.getFlowName(), flowName);
+    Assert.assertEquals(event.getJobName(), jobName);
+    Assert.assertEquals(event.getFlowExecutionId(), 
Long.valueOf(flowExecutionId));
+    Assert.assertEquals(event.getJobStatus(), JobStatus.SUCCEEDED);
+    Assert.assertEquals(event.getExecutorUrl(), "hostName");
+    Assert.assertEquals(event.getIssues().size(), 1);
+  }
+
+  private Issue createTestIssue(String summary, String code, IssueSeverity 
severity) {
+    return 
Issue.builder().summary(summary).code(code).time(ZonedDateTime.now()).severity(severity).build();
+  }
+
+
+  public class MockGaaSObservabilityProducer extends 
GaaSObservabilityEventProducer {
+    public MockGaaSObservabilityProducer(State state, 
MultiContextIssueRepository issueRepository) {
+      super(state, issueRepository);
+    }
+    // Send the events to the class test queue, so tests should not run 
concurrently
+    @Override
+    protected void sendUnderlyingEvent(GaaSObservabilityEventExperimental 
event) {
+      emittedEvents.add(event);

Review Comment:
   No longer needed, now tests should support concurrent test execs





Issue Time Tracking
-------------------

    Worklog Id:     (was: 839788)
    Time Spent: 2h 40m  (was: 2.5h)

> Emit GaaSObservabilityEvent
> ---------------------------
>
>                 Key: GOBBLIN-1764
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1764
>             Project: Apache Gobblin
>          Issue Type: New Feature
>          Components: gobblin-service
>            Reporter: William Lo
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> GaaSObservabilityEvents are a new events that provides a job summary from 
> pipelines in GaaS. It differs from GobblinTrackingEvents as it runs once per 
> job pipeline, and it intended to be easily queryable and alert on.
> We want to emit this observability event from GaaS by deriving it from a 
> job's job status. Since this feature is Experimental and WIP, it is not 
> expected to fill out all of the fields immediately.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to