Skip to content

Commit f317157

Browse files
authored
Merge pull request #35 from OferMania/23
AUE-23: When key doesn't exist, prohibits reject rules specifying ver…
2 parents 2da4cdb + f8f6819 commit f317157

4 files changed

Lines changed: 116 additions & 1 deletion

File tree

patches/nonexistant-rr.patch

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Forced nonexistant key to ban reject-rules specifying versionLE or versionNE
2+
3+
From: nobody <nobody@nowhere>
4+
5+
6+
---
7+
src/ObjectManager.cc | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/ObjectManager.cc b/src/ObjectManager.cc
11+
index 9c2d3b0c..5f4a6e79 100644
12+
--- a/src/ObjectManager.cc
13+
+++ b/src/ObjectManager.cc
14+
@@ -2893,7 +2893,7 @@ Status
15+
ObjectManager::rejectOperation(const RejectRules* rejectRules, uint64_t version)
16+
{
17+
if (version == VERSION_NONEXISTENT) {
18+
- if (rejectRules->doesntExist)
19+
+ if (rejectRules->doesntExist || rejectRules->versionLeGiven || rejectRules->versionNeGiven)
20+
return STATUS_OBJECT_DOESNT_EXIST;
21+
return STATUS_OK;
22+
}

patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ bindings-migration.patch
1313
log-sse42-status.patch
1414
rpcwrapper-logging-fix.patch
1515
table-enumerator.patch
16+
nonexistant-rr.patch

testing/cluster_test_utils.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,75 @@ def drop_tables(ensemble, table_names):
149149
for table_name in table_names:
150150
r.drop_table(table_name)
151151

152+
def output_logs_detached(docker_containers, path="/src/tmp"):
153+
if not os.path.exists(path):
154+
os.makedirs(path)
155+
for container in docker_containers:
156+
outfile = '%s/%s.out' % (path, container.name)
157+
f = open(outfile, 'wb')
158+
# make a stream of output logs to iterate and write to file
159+
# (uses less memory than storing the container log as a string),
160+
# and don't keep the stream open for new logs, since we want
161+
# to get thru outputting whatever we got for this container
162+
# before doing same for next container.
163+
for line in container.logs(stream=True, follow=False):
164+
f.write(line)
165+
f.close()
166+
167+
def output_zk_detached(ensemble, path="/src/tmp"):
168+
if not os.path.exists(path):
169+
os.makedirs(path)
170+
zk_client = get_zookeeper_client(ensemble)
171+
zk_table_configs = [
172+
ZkTableConfiguration(
173+
outfile = "config.out",
174+
zk_path = "/zookeeper/config",
175+
proto = "string",
176+
is_leaf = True),
177+
ZkTableConfiguration(
178+
outfile = "quota.out",
179+
zk_path = "/zookeeper/quota",
180+
proto = "string",
181+
is_leaf = True),
182+
ZkTableConfiguration(
183+
outfile = "coordinatorClusterClock.out",
184+
zk_path = "/ramcloud/main/coordinatorClusterClock",
185+
proto = CoordinatorClusterClock_pb2.CoordinatorClusterClock(),
186+
is_leaf = True),
187+
ZkTableConfiguration(
188+
outfile = "tables.out",
189+
zk_path = "/ramcloud/main/tables",
190+
proto = Table_pb2.Table(),
191+
is_leaf = False),
192+
ZkTableConfiguration(
193+
outfile = "tableManager.out",
194+
zk_path = "/ramcloud/main/tableManager",
195+
proto = TableManager_pb2.TableManager(),
196+
is_leaf = True),
197+
ZkTableConfiguration(
198+
outfile = "coordinator.out",
199+
zk_path = "/ramcloud/main/coordinator",
200+
proto = "string",
201+
is_leaf = True),
202+
ZkTableConfiguration(
203+
outfile = "servers.out",
204+
zk_path = "/ramcloud/main/servers",
205+
proto = ServerListEntry_pb2.ServerListEntry(),
206+
is_leaf = False),
207+
ZkTableConfiguration(
208+
outfile = "coordinatorUpdateManager.out",
209+
zk_path = "/ramcloud/main/coordinatorUpdateManager",
210+
proto = CoordinatorUpdateInfo_pb2.CoordinatorUpdateInfo(),
211+
is_leaf = True),
212+
ZkTableConfiguration(
213+
outfile = "clientLeaseAuthority.out",
214+
zk_path = "/ramcloud/main/clientLeaseAuthority",
215+
proto = "string",
216+
is_leaf = False),
217+
]
218+
for zk_table_config in zk_table_configs:
219+
zk_table_config.dump(path, zk_client)
220+
152221
# ClusterTest Usage in Python interpreter:
153222
# >>> import cluster_test_utils as ctu
154223
# >>> x = ctu.ClusterTest()

testing/ramcloud_test_cluster.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22
import argparse
33
import sys
44

5+
# If you're trying to make fake data in RAMCloud, this works from Python3 interpreter,
6+
# assuming you started up the default 3-node test cluster:
7+
#
8+
# >>> import ramcloud
9+
# >>> import cluster_test_utils as ctu
10+
# >>> rc = ramcloud.RAMCloud()
11+
# >>> rc.connect('zk:10.0.1.1:2181,10.0.1.2:2181,10.0.1.3:2181', 'main')
12+
# >>> rc.create_table('test')
13+
# >>> tid = rc.get_table_id('test')
14+
# >>> rc.write(tid, 'testKey', 'testValue')
15+
# >>> rc.read(tid, 'testKey')
16+
517
if __name__ == '__main__':
618
parser = argparse.ArgumentParser()
719
parser.add_argument('--action', '-a', metavar='A', type=str, default="status",
8-
help="Defines the action to take: status, reset, start, stop")
20+
help="Defines the action to take: status, reset, log, start, stop")
921
parser.add_argument('--nodes', '-n', type=int, default=3,
1022
help="Number of zk, rc-coordinator, and rc-server instances to bring up. Only relevant when there's no cluster up yet. Default is 3")
23+
parser.add_argument('--path', '-p', type=str, default="/src/tmp",
24+
help="Path to place logs in when action is set to \"log\"")
1125

1226
args = parser.parse_args()
1327

1428
print("action =",args.action)
1529
print("nodes =",args.nodes)
30+
print("path =",args.path)
1631
if (args.action == "start"):
1732
x = ctu.ClusterTest()
1833
x.setUp(num_nodes = args.nodes)
@@ -21,6 +36,14 @@
2136
elif (args.action == "stop"):
2237
docker_network, docker_containers = ctu.get_status()
2338
ctu.destroy_network_and_containers(docker_network, docker_containers)
39+
elif (args.action == "log"):
40+
docker_network, docker_containers = ctu.get_status()
41+
if (not docker_network or not docker_containers):
42+
print("No network or containers currently up to log")
43+
exit()
44+
ensemble = ctu.get_ensemble(len(docker_containers))
45+
ctu.output_logs_detached(docker_containers, args.path)
46+
ctu.output_zk_detached(ensemble, args.path)
2447
elif (args.action == "reset"):
2548
docker_network, docker_containers = ctu.get_status()
2649
if (not docker_network):

0 commit comments

Comments
 (0)