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

ASF GitHub Bot logged work on HADOOP-17511:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/May/21 10:59
            Start Date: 24/May/21 10:59
    Worklog Time Spent: 10m 
      Work Description: steveloughran commented on a change in pull request 
#2807:
URL: https://github.com/apache/hadoop/pull/2807#discussion_r637863394



##########
File path: 
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/audit/TestAuditSpanLifecycle.java
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.hadoop.fs.s3a.audit;
+
+import java.util.List;
+
+import com.amazonaws.handlers.RequestHandler2;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.store.audit.AuditSpan;
+
+import static org.apache.hadoop.fs.s3a.audit.AuditTestSupport.noopAuditConfig;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Unit tests related to span lifecycle.
+ */
+public class TestAuditSpanLifecycle extends AbstractAuditingTest {
+
+  private Configuration conf;
+
+  private AuditSpan resetSpan;
+
+  @Before
+  public void setup() throws Exception {
+    super.setup();
+    resetSpan = getManager().getActiveAuditSpan();
+  }
+
+  protected Configuration createConfig() {
+    return noopAuditConfig();
+  }
+
+  /**
+   * Core lifecycle (remember: the service has already been started).
+   */
+  @Test
+  public void testStop() throws Throwable {
+    getManager().stop();
+  }
+
+  @Test
+  public void testCreateRequestHandlers() throws Throwable {
+    List<RequestHandler2> handlers
+        = getManager().createRequestHandlers();
+    assertThat(handlers).isNotEmpty();
+  }
+
+  @Test
+  public void testInitialSpanIsInvalid() throws Throwable {
+    assertThat(resetSpan)
+        .matches(f -> !f.isValidSpan(), "is invalid");
+  }
+
+  @Test
+  public void testCreateCloseSpan() throws Throwable {
+    AuditSpan span = getManager().createSpan("op", null, null);
+    assertThat(span)
+        .matches(AuditSpan::isValidSpan, "is valid");
+    assertActiveSpan(span);
+    // activation when already active is no-op
+    span.activate();
+    assertActiveSpan(span);
+    // close the span
+    span.close();
+    // the original span is restored.
+    assertActiveSpan(resetSpan);
+  }
+
+  @Test
+  public void testSpanActivation() throws Throwable {
+    // real activation switches spans in the current thead.
+
+    AuditSpan span1 = getManager().createSpan("op1", null, null);
+    AuditSpan span2 = getManager().createSpan("op2", null, null);
+    assertActiveSpan(span2);
+    // switch back to span 1
+    span1.activate();
+    assertActiveSpan(span1);
+    // then to span 2
+    span2.activate();
+    assertActiveSpan(span2);
+    span2.close();
+

Review comment:
       ok, added span1 close & assert still in reset span. Did something 
similarish in the test case underneath (accidentally; I'd navigated to the 
wrong line)




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 601111)
    Time Spent: 19h 50m  (was: 19h 40m)

> Add an Audit plugin point for S3A auditing/context
> --------------------------------------------------
>
>                 Key: HADOOP-17511
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17511
>             Project: Hadoop Common
>          Issue Type: Sub-task
>    Affects Versions: 3.3.1
>            Reporter: Steve Loughran
>            Assignee: Steve Loughran
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 19h 50m
>  Remaining Estimate: 0h
>
> Add a way for auditing tools to correlate S3 object calls with Hadoop FS API 
> calls.
> Initially just to log/forward to an auditing service.
> Later: let us attach them as parameters in S3 requests, such as opentrace 
> headeers or (my initial idea: http referrer header -where it will get into 
> the log)
> Challenges
> * ensuring the audit span is created for every public entry point. That will 
> have to include those used in s3guard tools, some defacto public APIs
> * and not re-entered for active spans. s3A code must not call back into the 
> FS API points
> * Propagation across worker threads



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to