[
https://issues.apache.org/jira/browse/HADOOP-18167?focusedWorklogId=760958&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-760958
]
ASF GitHub Bot logged work on HADOOP-18167:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 22/Apr/22 17:18
Start Date: 22/Apr/22 17:18
Worklog Time Spent: 10m
Work Description: hchaverri commented on code in PR #4092:
URL: https://github.com/apache/hadoop/pull/4092#discussion_r856427800
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java:
##########
@@ -579,4 +634,85 @@ public void testEmptyToken() throws IOException {
assertEquals(token1, token2);
assertEquals(token1.encodeToUrlString(), token2.encodeToUrlString());
}
+
+ @Test
+ public void testDelegationTokenSecretManagerMetrics() throws Exception {
+ TestDelegationTokenSecretManager dtSecretManager =
+ new TestDelegationTokenSecretManager(24*60*60*1000,
+ 10*1000, 1*1000, 60*60*1000);
+ try {
+ dtSecretManager.startThreads();
+
+ final Token<TestDelegationTokenIdentifier> token =
callAndValidateMetrics(
+ dtSecretManager, dtSecretManager.getMetrics().getStoreToken(),
"storeToken",
+ () -> generateDelegationToken(dtSecretManager, "SomeUser",
"JobTracker"), 1);
+
+ callAndValidateMetrics(dtSecretManager,
dtSecretManager.getMetrics().getUpdateToken(),
+ "updateToken", () -> dtSecretManager.renewToken(token,
"JobTracker"), 1);
+
+ callAndValidateMetrics(dtSecretManager,
dtSecretManager.getMetrics().getRemoveToken(),
+ "removeToken", () -> dtSecretManager.cancelToken(token,
"JobTracker"), 1);
+ } finally {
+ dtSecretManager.stopThreads();
+ }
+ }
+
+ @Test
+ public void testDelegationTokenSecretManagerMetricsFailures() throws
Exception {
+ int errorSleepMillis = 200;
+ TestFailureDelegationTokenSecretManager dtSecretManager =
+ new TestFailureDelegationTokenSecretManager(errorSleepMillis);
+
+ try {
+ dtSecretManager.startThreads();
+
+ final Token<TestDelegationTokenIdentifier> token =
+ generateDelegationToken(dtSecretManager, "SomeUser", "JobTracker");
+
+ dtSecretManager.setThrowError(true);
+
+ callAndValidateFailureMetrics(dtSecretManager, "storeToken", 1, 1, false,
+ errorSleepMillis,
+ () -> generateDelegationToken(dtSecretManager, "SomeUser",
"JobTracker"));
+
+ callAndValidateFailureMetrics(dtSecretManager, "updateToken", 1, 2, true,
+ errorSleepMillis, () -> dtSecretManager.renewToken(token,
"JobTracker"));
+
+ callAndValidateFailureMetrics(dtSecretManager, "removeToken", 1, 3, true,
+ errorSleepMillis, () -> dtSecretManager.cancelToken(token,
"JobTracker"));
+ } finally {
+ dtSecretManager.stopThreads();
+ }
+ }
+
+ private <T> T callAndValidateMetrics(TestDelegationTokenSecretManager
dtSecretManager,
+ MutableRate metric, String statName, Callable<T> callable, int
expectedCount)
+ throws Exception {
+ MeanStatistic stat = IOStatisticAssertions.lookupMeanStatistic(
+ dtSecretManager.getMetrics().getIoStatistics(), statName + ".mean");
+ Assert.assertEquals(expectedCount - 1, metric.lastStat().numSamples());
+ Assert.assertEquals(expectedCount - 1, stat.getSamples());
+ T returnedObject = callable.call();
+ Assert.assertEquals(expectedCount, metric.lastStat().numSamples());
Review Comment:
I've updated to use assertEquals() only
Issue Time Tracking
-------------------
Worklog Id: (was: 760958)
Time Spent: 5.5h (was: 5h 20m)
> Add metrics to track delegation token secret manager operations
> ---------------------------------------------------------------
>
> Key: HADOOP-18167
> URL: https://issues.apache.org/jira/browse/HADOOP-18167
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: Hector Sandoval Chaverri
> Priority: Major
> Labels: pull-request-available
> Attachments: HADOOP-18167-branch-2.10-2.patch,
> HADOOP-18167-branch-2.10-3.patch, HADOOP-18167-branch-2.10.patch
>
> Time Spent: 5.5h
> Remaining Estimate: 0h
>
> New metrics to track operations that store, update and remove delegation
> tokens in implementations of AbstractDelegationTokenSecretManager. This will
> help evaluate the impact of using different secret managers and add
> optimizations.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]