Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
d6debd1b
Commit
d6debd1b
authored
11 years ago
by
Rob Adams
Browse files
Options
Downloads
Patches
Plain Diff
Make unit test more reliable on slow machine
parent
bc54d863
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/java/org/sdnplatform/sync/internal/TUtils.java
+15
-1
15 additions, 1 deletion
src/test/java/org/sdnplatform/sync/internal/TUtils.java
src/test/java/org/sdnplatform/sync/internal/version/VectorClockTest.java
+15
-13
15 additions, 13 deletions
...rg/sdnplatform/sync/internal/version/VectorClockTest.java
with
30 additions
and
14 deletions
src/test/java/org/sdnplatform/sync/internal/TUtils.java
+
15
−
1
View file @
d6debd1b
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright (c) 2013 Big Switch Networks, Inc.
*
* Licensed 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
...
...
@@ -47,7 +48,7 @@ public class TUtils {
/**
* Get a vector clock with events on the sequence of nodes given So
* getClock(1,1,2,2,2) means a clock that has two writes on node 1 and 3
* writes on node 2.
* writes on node 2.
The timestamp will be the current time
*
* @param nodes The sequence of nodes
* @return A VectorClock initialized with the given sequence of events
...
...
@@ -56,6 +57,19 @@ public class TUtils {
VectorClock
clock
=
new
VectorClock
();
return
increment
(
clock
,
nodes
);
}
/**
* Get a vector clock with a the given timestamp and events on the
* sequence of nodes given So getClock(1,1,2,2,2) means a clock that has
* two writes on node 1 and 3 writes on node 2.
*
* @param nodes The sequence of nodes
* @return A VectorClock initialized with the given sequence of events
*/
public
static
VectorClock
getClock
(
long
timestamp
,
int
...
nodes
)
{
VectorClock
clock
=
new
VectorClock
(
timestamp
);
return
increment
(
clock
,
nodes
);
}
/**
* Record events for the given sequence of nodes
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/sdnplatform/sync/internal/version/VectorClockTest.java
+
15
−
13
View file @
d6debd1b
...
...
@@ -36,8 +36,9 @@ import com.google.common.collect.Lists;
public
class
VectorClockTest
{
@Test
public
void
testEqualsAndHashcode
()
{
VectorClock
one
=
getClock
(
1
,
2
);
VectorClock
other
=
getClock
(
1
,
2
);
long
now
=
5555555555L
;
VectorClock
one
=
getClock
(
now
,
1
,
2
);
VectorClock
other
=
getClock
(
now
,
1
,
2
);
assertEquals
(
one
,
other
);
assertEquals
(
one
.
hashCode
(),
other
.
hashCode
());
}
...
...
@@ -62,20 +63,21 @@ public class VectorClockTest {
public
void
testMerge
()
{
// merging two clocks should create a clock contain the element-wise
// maximums
assertEquals
(
"Two empty clocks merge to an empty clock."
,
getClock
().
merge
(
getClock
()),
getClock
());
getClock
().
merge
(
getClock
())
.
getEntries
()
,
getClock
()
.
getEntries
()
);
assertEquals
(
"Merge of a clock with itself does nothing"
,
getClock
(
1
).
merge
(
getClock
(
1
)),
getClock
(
1
));
assertEquals
(
getClock
(
1
).
merge
(
getClock
(
2
)),
getClock
(
1
,
2
));
assertEquals
(
getClock
(
1
).
merge
(
getClock
(
1
,
2
)),
getClock
(
1
,
2
));
assertEquals
(
getClock
(
1
,
2
).
merge
(
getClock
(
1
)),
getClock
(
1
,
2
));
getClock
(
1
).
merge
(
getClock
(
1
))
.
getEntries
()
,
getClock
(
1
)
.
getEntries
()
);
assertEquals
(
getClock
(
1
).
merge
(
getClock
(
2
))
.
getEntries
()
,
getClock
(
1
,
2
)
.
getEntries
()
);
assertEquals
(
getClock
(
1
).
merge
(
getClock
(
1
,
2
))
.
getEntries
()
,
getClock
(
1
,
2
)
.
getEntries
()
);
assertEquals
(
getClock
(
1
,
2
).
merge
(
getClock
(
1
))
.
getEntries
()
,
getClock
(
1
,
2
)
.
getEntries
()
);
assertEquals
(
"Two-way merge fails."
,
getClock
(
1
,
1
,
1
,
2
,
3
,
5
).
merge
(
getClock
(
1
,
2
,
2
,
4
)),
getClock
(
1
,
1
,
1
,
2
,
2
,
3
,
4
,
5
));
assertEquals
(
getClock
(
2
,
3
,
5
).
merge
(
getClock
(
1
,
2
,
2
,
4
,
7
)),
getClock
(
1
,
2
,
2
,
3
,
4
,
5
,
7
));
getClock
(
1
,
1
,
1
,
2
,
3
,
5
).
merge
(
getClock
(
1
,
2
,
2
,
4
))
.
getEntries
()
,
getClock
(
1
,
1
,
1
,
2
,
2
,
3
,
4
,
5
)
.
getEntries
()
);
assertEquals
(
getClock
(
2
,
3
,
5
).
merge
(
getClock
(
1
,
2
,
2
,
4
,
7
))
.
getEntries
()
,
getClock
(
1
,
2
,
2
,
3
,
4
,
5
,
7
)
.
getEntries
()
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment