Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cse138-assignment-4-test-suite
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Korben Tompkin
cse138-assignment-4-test-suite
Commits
0d17d669
Verified
Commit
0d17d669
authored
1 month ago
by
Christian Thomas Knab
Browse files
Options
Downloads
Patches
Plain Diff
view change helper functions to modify shards
parent
93fddce2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/basic/basic.py
+13
-1
13 additions, 1 deletion
tests/basic/basic.py
utils/containers.py
+9
-1
9 additions, 1 deletion
utils/containers.py
with
22 additions
and
2 deletions
tests/basic/basic.py
+
13
−
1
View file @
0d17d669
...
...
@@ -9,9 +9,21 @@ def basic_kv_1(conductor: ClusterConductor, dir, log: Logger):
with
KVSTestFixture
(
conductor
,
dir
,
log
,
node_count
=
4
)
as
fx
:
c
=
KVSMultiClient
(
fx
.
clients
,
"
client
"
,
log
)
conductor
.
add_shard
(
"
shard1
"
,
conductor
.
get_nodes
(
0
,
2
))
conductor
.
add_shard
(
"
shard2
"
,
conductor
.
get_nodes
(
2
,
4
))
fx
.
broadcast_view
(
conductor
.
get_shard_view
())
# examples of modifying shards
# conductor.add_shard("shard2", conductor.get_nodes(2, 3))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.add_node_to_shard("shard2", conductor.get_node(3))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.remove_node_from_shard("shard1", conductor.get_node(0))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.remove_shard("shard1")
# fx.broadcast_view(conductor.get_shard_view())
r
=
c
.
put
(
0
,
"
x
"
,
"
1
"
)
assert
r
.
ok
,
f
"
expected ok for new key, got
{
r
.
status_code
}
"
...
...
This diff is collapsed.
Click to expand it.
utils/containers.py
+
9
−
1
View file @
0d17d669
...
...
@@ -463,6 +463,7 @@ class ClusterConductor:
def
get_node
(
self
,
index
):
return
self
.
nodes
[
index
]
# from `start`` to `end`. Note that `end` is not inclusive
def
get_nodes
(
self
,
start
=
0
,
end
=
None
):
if
start
<
0
:
raise
ValueError
(
"
Start index cannot be negative.
"
)
...
...
@@ -477,16 +478,23 @@ class ClusterConductor:
return
self
.
nodes
[
start
:
end
]
def
add_shard
(
self
,
shard_name
:
str
,
nodes
:
List
[
ClusterNode
]):
# add the nodes
if
shard_name
not
in
self
.
shards
:
self
.
shards
[
shard_name
]
=
[]
self
.
shards
[
shard_name
]
=
nodes
def
remove_shard
(
self
,
shard_name
:
str
):
del
self
.
shards
[
shard_name
]
def
add_node_to_shard
(
self
,
shard_name
:
str
,
node
:
ClusterNode
):
if
shard_name
not
in
self
.
shards
:
self
.
shards
[
shard_name
]
=
[]
self
.
shards
[
shard_name
].
append
(
node
)
def
remove_node_from_shard
(
self
,
shard_name
:
str
,
node
:
ClusterNode
):
if
shard_name
not
in
self
.
shards
:
return
self
.
shards
[
shard_name
].
remove
(
node
)
def
get_shard_view
(
self
)
->
dict
:
return
{
shard
:
[
node
.
get_view
()
for
node
in
nodes
]
...
...
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