Netflix / dynomite

A generic dynamo implementation for different k-v storage engines
Apache License 2.0
4.2k stars 534 forks source link

Refactor test framework to easily expand on cluster management #617

Closed smukil closed 6 years ago

smukil commented 6 years ago

This patch takes a lot of the code from test/cluster_generator.py and refactors it into easily manageable classes which allows for easily creating and destroying a dynomite cluster in a local test environment. Refer to the last paragraph of this commit message for the motivation behind this patch.

To create a dynomite cluster, now it's as simple as doing the following:

cluster = DynoCluster(args.request_file, ips) cluster.launch() # Run all the required tests cluster.teardown()

This patch does this by forming clear relations between DynoCluster, DynoSpec, DynoNode and RedisNode.

DynoCluster --manages--> list(DynoSpec), list(DynoNode) DynoNode --manages--> RedisNode DynoNode and DynoSpec have a 1:1 relationship.

In the future, we should decouple RedisNode and DynoNode and abstract away specific storage node classes to a generic class. Eg: 'RedisNode' implements 'StorageNode', and 'DynoNode' directly uses only 'StorageNode'.

This patch also fixes a small bug where the incorrect port is used for the client listening port.

This patch currently breaks other standalone scripts like func_test.py and large_value_test.py. This will be cleaned up in a future commit, and IMO it's not a serious issue as it's difficult to already use those scripts since they assume that a cluster with a very specific configuration is already setup (which is not that simple to do manually today).

The initial motivation behind this patch is to create scripts to only start or only stop a dynomite cluster for the purpose of manual testing against a cluster. Before this patch, cluster_generator.py always cleaned up the resources on exit. Future commits will introduce new scripts like start_cluster.py and teardown_cluster.py which will allow developers to just start a cluster and run tests against it and then tear it down later. Other things that this patch enables is to do hypothetical experiments like dual running against 2 dynomite clusters with different configurations, expanding the framework to run only a subset of tests based on user flags passed to cluster_generator.py, etc.

Future TODO: Add code comments to classes and methods as necessary.

smukil commented 6 years ago

I'm merging this to unblock myself. If anyone has more review comments for this in the future, I'll address them in a separate patch.