HW 6
To test the KV store, you can build the program by running
go build -mod vendor -o tpc main.go
You will then have a binary called tpc (make sure you don't commit this). To test the application, you must start some number of 2PC followers and one 2PC leader. You can start a follower with the following command:
./tpc --tpc-follower --logtostderr \
--journal-dir <path to journal file> \
--kv-dir <path to key value directory> \
--port <port> --name <name>
To start a leader, run the command:
./tpc --tpc-leader --logtostderr \
--journal-dir <path to journal file> \
--follower <url of follower> \
--port <port> --name <name>
The URL of the follower is comprised of a hostname and a port such as localhost:50001. To connect multiple followers to a leader, you can set the --follower flag multiple times.
There is also the option to use a script to start a 2PC cluster automatically. Once you built the tpc binary, run the command python3 tpc.py <num-followers> to automatically start a cluster with the specified number of followers and a leader. Use Control-C to shut down the cluster when you are done. This cluster automatically exposes the leader at localhost:50000.
You can run end to end tests on the cluster with python3 client.py <leader-url>. It automatically connects to the leader and starts a simple shell where you can execute GET and PUT commands.
We also provide a framework for working with mocked followers and leaders. Take a look inside client.py to see how we use a fake follower and a fake leader in order to control the actions of each. We use this in order to run some tests, but if you want to use it you will need to write a python script that takes advantage of the mocks.
In the file test.py, we provide a framework very similar to out autograding framework. We also provide 3 test cases identical to the the cases used on the autograder, for you to use as an example to write your own tests. These examples also use the mock leader and mock followers, which is very useful for only testing either the follower or the leader in isolation.
Copy link