You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2024/01/04 21:01:30 UTC
[PR] HDDS-10060. Restrict awaitility to test scope [ozone]
adoroszlai opened a new pull request, #5923:
URL: https://github.com/apache/ozone/pull/5923
## What changes were proposed in this pull request?
(draft, on top of HDDS-10058)
Awaitility is a test library. Using it in production code leaks `hamcrest` (its transitive dependency).
This change restricts Awaitility to `test` scope, replacing production use with similar functionality from Ratis utilities.
https://issues.apache.org/jira/browse/HDDS-10060
## How was this patch tested?
CI:
https://github.com/adoroszlai/ozone/actions/runs/7409693008
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443264632
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
Using `number of attempts` is fine as well. It is equivalent to poll max time as you said.
I was thinking if we can get rid of `LambdaTestUtils#await` and `GenericTestUtils#waitFor` if we add it into JavaUtils. But it could be future improvement and can be done later.
For now, I'm OK if you leave it as it is or use `number of attempts`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443250643
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
We could even get rid of this wrapper if using "number of attempts" is fine.
(600 attempts with 100ms sleep seems to be equivalent to 60s max. wait)
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #5923:
URL: https://github.com/apache/ozone/pull/5923
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #5923:
URL: https://github.com/apache/ozone/pull/5923#issuecomment-1879313367
Thanks a lot @hemantk-12 for reviewing this.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443180770
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
nit: I think we should add it to [HddsUtils](https://github.com/apache/ozone/blob/master/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java) or [JavaUtils](https://github.com/apache/ozone/blob/master/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/JavaUtils.java).
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443264632
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
Using "number of attempts" is fine as well. It is equivalent to poll max time as you said.
I was thinking if we can get rid of `LambdaTestUtils#await` and `GenericTestUtils#waitFor` if we add it into JavaUtils. But it could be future improvement and can be done later.
For now, I'm OK if you leave it as it or use "number of attempts".
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443239885
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
My understanding is the usage of `attemptUntilTrue` might increase over the time so better to have it in [HddsUtils](https://github.com/apache/ozone/blob/master/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java) or [JavaUtils](https://github.com/apache/ozone/blob/master/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/JavaUtils.java). `RatisHelper` seems like a util/helper class for Ratis related stuff not general Ozone util.
If you think that it is better to leave it here and decide it later, I am fine with that too for now.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443220670
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
Thanks @hemantk-12 for the review.
At first I considered `JavaUtils`, since it matches the class name in Ratis, but its scope in Ozone is very different (limited) compared to Ratis. I'm not sure I'd like to grow it like that.
I chose `RatisHelper` since this new `attemptUntilTrue` is just a wrapper around the existing method in Ratis.
I'd prefer not having to move the method now.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-10060. Restrict awaitility to test scope [ozone]
Posted by "hemantk-12 (via GitHub)" <gi...@apache.org>.
hemantk-12 commented on code in PR #5923:
URL: https://github.com/apache/ozone/pull/5923#discussion_r1443264632
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -603,4 +610,32 @@ private static void resetPriorities(RaftGroup original, RaftClient client) {
// Not re-thrown in order to keep the main exception, if there is any.
}
}
+
+ /**
+ * Similar to {@link JavaUtils#attemptUntilTrue(BooleanSupplier, int, TimeDuration, String, Logger)},
+ * but:
+ * <li>takes max. {@link Duration} instead of number of attempts</li>
+ * <li>accepts {@link Duration} instead of {@link TimeDuration} for sleep time</li>
+ *
+ * @return true if attempt was successful,
+ * false if wait for condition to become true timed out or was interrupted
+ */
+ public static boolean attemptUntilTrue(BooleanSupplier condition, Duration pollInterval, Duration timeout) {
Review Comment:
Using "number of attempts" is fine as well. It is equivalent to poll max time as you said.
I was thinking if we can get rid of `LambdaTestUtils#await` and `GenericTestUtils#waitFor` if we add it into JavaUtils. But it could be future improvement and can be done later.
For now, I'm OK if you leave it as it is or use "number of attempts".
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org