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
Evan Kelly Jones
cse138-assignment-4-test-suite
Commits
6642e689
Commit
6642e689
authored
1 month ago
by
Alexander Aghili
Browse files
Options
Downloads
Plain Diff
Merge branch 'port_asgn3' of git.ucsc.edu:awaghili/cse138-assignment-4-test-suite into port_asgn3
parents
b2730fca
3a037888
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__main__.py
+4
-0
4 additions, 0 deletions
__main__.py
tests/proxy/basic_proxy.py
+43
-0
43 additions, 0 deletions
tests/proxy/basic_proxy.py
utils/containers.py
+18
-5
18 additions, 5 deletions
utils/containers.py
with
65 additions
and
5 deletions
__main__.py
+
4
−
0
View file @
6642e689
...
...
@@ -79,6 +79,8 @@ from .tests.basic.basic import BASIC_TESTS
from
.tests.asgn3.availability.availability_basic
import
AVAILABILITY_TESTS
from
.tests.asgn3.causal_consistency.causal_basic
import
CAUSAL_TESTS
from
.tests.asgn3.eventual_consistency.convergence_basic
import
CONVERGENCE_TESTS
# from .tests.asgn3.view_change.view_change_basic import VIEW_CHANGE_TESTS
from
.tests.proxy.basic_proxy
import
PROXY_TESTS
TEST_SET
=
[]
TEST_SET
.
append
(
TestCase
(
"
hello_cluster
"
,
hello_cluster
))
...
...
@@ -86,6 +88,8 @@ TEST_SET.extend(BASIC_TESTS)
TEST_SET
.
extend
(
AVAILABILITY_TESTS
)
TEST_SET
.
extend
(
CAUSAL_TESTS
)
TEST_SET
.
extend
(
CONVERGENCE_TESTS
)
TEST_SET
.
extend
(
PROXY_TESTS
)
# TEST_SET.extend(VIEW_CHANGE_TESTS)
# set to True to stop at the first failing test
FAIL_FAST
=
True
...
...
This diff is collapsed.
Click to expand it.
tests/proxy/basic_proxy.py
0 → 100644
+
43
−
0
View file @
6642e689
from
...utils.containers
import
ClusterConductor
from
...utils.testcase
import
TestCase
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
):
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
]))
conductor
.
add_shard
(
"
shard2
"
,
conductor
.
get_nodes
([
2
,
3
]))
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
,
51
):
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
assert
r
.
ok
,
f
"
expected ok for get, got
{
r
.
status_code
}
"
res
=
r
.
json
()[
"
items
"
]
print
(
"
res-- {}
"
,
res
)
return
True
,
"
ok
"
def
partitioned_shards
(
conductor
:
ClusterConductor
,
dir
,
log
:
Logger
):
with
KVSTestFixture
(
conductor
,
dir
,
log
,
node_count
=
4
)
as
fx
:
###
# test 2
# partition the shards
# put a bunch of keys
# we MUST probablistically encounter some hanging there.
# 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
This diff is collapsed.
Click to expand it.
utils/containers.py
+
18
−
5
View file @
6642e689
...
...
@@ -107,7 +107,7 @@ class ClusterConductor:
def
dump_all_container_logs
(
self
,
dir
):
self
.
log
(
"
dumping logs of kvs containers
"
)
container_pattern
=
"
^kvs_.*
"
container_pattern
=
f
"
^kvs_
{
self
.
group_id
}
_
.*
"
container_regex
=
re
.
compile
(
container_pattern
)
containers
=
self
.
_list_containers
()
...
...
@@ -143,6 +143,17 @@ class ClusterConductor:
error_prefix
=
f
"
failed to remove container
{
name
}
"
,
)
def
_remove_containers
(
self
,
names
:
list
[
str
])
->
None
:
if
len
(
names
)
==
0
:
return
self
.
log
(
f
"
removing containers
{
names
}
"
)
run_cmd_bg
(
self
.
_make_remove_cmd
(
names
[
0
])
+
names
[
1
:],
verbose
=
True
,
error_prefix
=
f
"
failed to remove containers
{
names
}
"
,
)
def
_remove_network
(
self
,
name
:
str
)
->
None
:
# remove a single network
self
.
log
(
f
"
removing network
{
name
}
"
)
...
...
@@ -184,10 +195,12 @@ class ClusterConductor:
# cleanup containers
self
.
log
(
f
"
cleaning up
{
'
group
'
if
group_only
else
'
all
'
}
containers
"
)
containers
=
self
.
_list_containers
()
for
container
in
containers
:
if
container
and
container_regex
.
match
(
container
):
self
.
_remove_container
(
container
)
containers_to_remove
=
[
container
for
container
in
containers
if
container
and
container_regex
.
match
(
container
)
]
self
.
_remove_containers
(
containers_to_remove
)
# cleanup networks
self
.
log
(
f
"
cleaning up
{
'
group
'
if
group_only
else
'
all
'
}
networks
"
)
networks
=
self
.
_list_networks
()
...
...
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