This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluo.git
The following commit(s) were added to refs/heads/main by this push:
new 0a91a85 Fixes flakiness in TimestampTrackerIT (#1109)
0a91a85 is described below
commit 0a91a85048bcd8147f55ba81da0621a60f1c291f
Author: Keith Turner <[email protected]>
AuthorDate: Mon Jan 11 10:24:12 2021 -0500
Fixes flakiness in TimestampTrackerIT (#1109)
---
.../fluo/integration/impl/TimestampTrackerIT.java | 39 ++++++++++++++++------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/TimestampTrackerIT.java
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/TimestampTrackerIT.java
index 7db1866..fba0c43 100644
---
a/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/TimestampTrackerIT.java
+++
b/modules/integration-tests/src/main/java/org/apache/fluo/integration/impl/TimestampTrackerIT.java
@@ -4,9 +4,9 @@
* 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
@@ -74,7 +74,9 @@ public class TimestampTrackerIT extends ITBaseImpl {
public void testTrackingWithZkUpdate() throws Exception {
TimestampTracker tracker = new TimestampTracker(env, new
TransactorID(env), 5);
final long ts1 = tracker.allocateTimestamp().getTxTimestamp();
- Thread.sleep(15);
+ while (!zkNodeExists(tracker) || tracker.getZookeeperTimestamp() !=
zkNodeValue(tracker)) {
+ Thread.sleep(5);
+ }
Assert.assertNotNull(ts1);
Assert.assertTrue(zkNodeExists(tracker));
Assert.assertNotNull(zkNodeValue(tracker));
@@ -85,10 +87,15 @@ public class TimestampTrackerIT extends ITBaseImpl {
Thread.sleep(15);
tracker.removeTimestamp(ts1);
Thread.sleep(15);
+ while (ts2 != zkNodeValue(tracker)) {
+ Thread.sleep(5);
+ }
Assert.assertEquals(ts2, tracker.getOldestActiveTimestamp());
Assert.assertEquals(ts2, zkNodeValue(tracker));
tracker.removeTimestamp(ts2);
- Thread.sleep(15);
+ while (zkNodeExists(tracker)) {
+ Thread.sleep(5);
+ }
Assert.assertTrue(tracker.isEmpty());
Assert.assertFalse(zkNodeExists(tracker));
tracker.close();
@@ -105,13 +112,19 @@ public class TimestampTrackerIT extends ITBaseImpl {
final long ts2 = tr2.allocateTimestamp().getTxTimestamp();
TimestampTracker tr3 = new TimestampTracker(env, new TransactorID(env), 5);
final long ts3 = tr3.allocateTimestamp().getTxTimestamp();
- Thread.sleep(15);
+ while (ts1 != getOldestTs()) {
+ Thread.sleep(5);
+ }
Assert.assertEquals(ts1, getOldestTs());
tr1.removeTimestamp(ts1);
- Thread.sleep(15);
+ while (ts2 != getOldestTs()) {
+ Thread.sleep(5);
+ }
Assert.assertEquals(ts2, getOldestTs());
tr2.removeTimestamp(ts2);
- Thread.sleep(15);
+ while (ts3 != getOldestTs()) {
+ Thread.sleep(5);
+ }
Assert.assertEquals(ts3, getOldestTs());
tr3.removeTimestamp(ts3);
tr1.close();
@@ -132,10 +145,14 @@ public class TimestampTrackerIT extends ITBaseImpl {
long oldestTs = Long.MAX_VALUE;
for (String child : children) {
- Long ts = LongUtil.fromByteArray(
- curator.getData().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS + "/"
+ child));
- if (ts < oldestTs) {
- oldestTs = ts;
+ try {
+ Long ts = LongUtil.fromByteArray(
+ curator.getData().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS +
"/" + child));
+ if (ts < oldestTs) {
+ oldestTs = ts;
+ }
+ } catch (NoNodeException nne) {
+ continue;
}
}