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
a3e304d5
Commit
a3e304d5
authored
1 month ago
by
Alexander Aghili
Browse files
Options
Downloads
Patches
Plain Diff
added new b asic prozxy
parent
2402d6f2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/proxy/basic_proxy.py
+38
-5
38 additions, 5 deletions
tests/proxy/basic_proxy.py
with
38 additions
and
5 deletions
tests/proxy/basic_proxy.py
+
38
−
5
View file @
a3e304d5
...
...
@@ -4,7 +4,7 @@ from ...utils.util import Logger
from
..helper
import
KVSMultiClient
,
KVSTestFixture
from
...utils.kvs_api
import
DEFAULT_TIMEOUT
def
basic_proxy
(
conductor
:
ClusterConductor
,
dir
,
log
:
Logger
):
def
basic_proxy
_one_client
(
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
,
1
]))
...
...
@@ -17,18 +17,51 @@ def basic_proxy(conductor: ClusterConductor, dir, log: Logger):
node_to_put
=
0
base_key
=
"
key
"
for
i
in
range
(
0
,
5
0
):
for
i
in
range
(
0
,
30
0
):
r
=
c
.
put
(
node_to_put
,
f
"
{
base_key
}{
i
}
"
,
f
"
{
i
}
"
,
timeout
=
10
)
assert
r
.
ok
,
f
"
expected ok for new key, got
{
r
.
status_code
}
"
node_to_put
+=
1
node_to_put
=
node_to_put
%
4
r
=
c
.
get_all
(
0
,
timeout
=
10
)
# should get all of shard 1's keys
r
=
c
.
get_all
(
0
,
timeout
=
None
)
# should get all of shard 1's keys
assert
r
.
ok
,
f
"
expected ok for get, got
{
r
.
status_code
}
"
items
=
r
.
json
()[
"
items
"
]
keys
=
items
.
keys
()
for
key
in
keys
:
r
=
c
.
get
(
2
,
key
,
timeout
=
10
)
r
=
c
.
get
(
2
,
key
,
timeout
=
30
)
assert
r
.
ok
,
f
"
expected ok for get, got
{
r
.
status_code
}
"
assert
r
.
json
()[
"
value
"
]
==
items
[
key
],
f
"
wrong value returned:
{
r
.
json
()
}
"
return
True
,
"
ok
"
def
basic_proxy_many_clients
(
conductor
:
ClusterConductor
,
dir
,
log
:
Logger
):
with
KVSTestFixture
(
conductor
,
dir
,
log
,
node_count
=
7
)
as
fx
:
c
=
KVSMultiClient
(
fx
.
clients
,
"
client
"
,
log
)
conductor
.
add_shard
(
"
shard1
"
,
conductor
.
get_nodes
([
0
,
1
]))
conductor
.
add_shard
(
"
shard2
"
,
conductor
.
get_nodes
([
2
,
3
]))
conductor
.
add_shard
(
"
shard3
"
,
conductor
.
get_nodes
([
4
,
5
,
6
]))
fx
.
broadcast_view
(
conductor
.
get_shard_view
())
# test 1
# put 50 keys (at least one proxy expected here)
# get_all() on one shard
# then ask the other shard for that key (proxy MUST happen here)
node_to_put
=
0
base_key
=
"
key
"
for
i
in
range
(
0
,
1000
):
c1
=
KVSMultiClient
(
fx
.
clients
,
"
client
"
,
log
)
r
=
c1
.
put
(
node_to_put
,
f
"
{
base_key
}{
i
}
"
,
f
"
{
i
}
"
,
timeout
=
10
)
assert
r
.
ok
,
f
"
expected ok for new key, got
{
r
.
status_code
}
"
node_to_put
+=
1
node_to_put
=
node_to_put
%
7
r
=
c
.
get_all
(
0
,
timeout
=
None
)
# should get all of shard 1's keys
assert
r
.
ok
,
f
"
expected ok for get, got
{
r
.
status_code
}
"
items
=
r
.
json
()[
"
items
"
]
keys
=
items
.
keys
()
for
key
in
keys
:
r
=
c
.
get
(
2
,
key
,
timeout
=
30
)
assert
r
.
ok
,
f
"
expected ok for get, got
{
r
.
status_code
}
"
assert
r
.
json
()[
"
value
"
]
==
items
[
key
],
f
"
wrong value returned:
{
r
.
json
()
}
"
...
...
@@ -44,4 +77,4 @@ def partitioned_shards(conductor: ClusterConductor, dir, log: Logger):
# have a time out where if it doesnt hang after like 50 keys, then its just wrong.
return
True
,
"
ok
"
PROXY_TESTS
=
[
TestCase
(
"
basic_proxy
"
,
basic_proxy
)]
\ No newline at end of file
PROXY_TESTS
=
[
TestCase
(
"
basic_proxy_one_client
"
,
basic_proxy_one_client
),
TestCase
(
"
basic_proxy_many_clients
"
,
basic_proxy_many_clients
)]
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