This project explores the use of unit testing and fuzz testing to enhance the deployment and validation of MongoDB clusters in cloud environments using Docker and Kubernetes. MongoDB's growing popularity for its flexibility and scalability underscores the importance of reliable deployment and operational testing in production settings. To address these challenges, we present an automated framework for MongoDB cluster setup, leveraging Docker and Kubernetes StatefulSets to streamline configuration, provide persistent storage, and manage replicas. The framework integrates unit testing to validate core MongoDB functionalities and employs fuzz testing with Atheris to assess resilience, edge-case handling, and execution path coverage under unpredictable inputs. While experimental results demonstrate automation and the detection of potential vulnerabilities, the scope is limited, necessitating further exploration of complementary testing approaches.
- M.Sc. in computer science and Engineering Graduate Fellowship recipient at Vanderbilt University.
- Incoming Online Master in computer science student at Georgia Tech.
- Email: [email protected]
- M.Sc. in computer science student at Vanderbilt University
- Email: [email protected]
- B.Sc. in computer science student at Vanderbilt University
- Email: [email protected]
- Professor in the Computer Science at Vanderbilt University
- Email: [email protected]
This project aims to simplify the deployment and evaluation of MongoDB by:
- Automating the setup of MongoDB clusters using Docker and Kubernetes.
- Providing a suite of unit tests to validate basic functionality of MongoDB interactions.
- Integrating fuzz testing, a type of automated software testing, to identify potential vulnerabilities.
- Automated MongoDB Setup: Easily deploy a MongoDB cluster locally or on Chameleon Cloud using Docker or Kubernetes.
- Unit Testing: Validate core MongoDB operations such as CRUD operations and replica set configurations.
- Fuzz Testing: Stress-test the MongoDB client or server with random or invalid inputs to identify crashes and vulnerabilities.
- Kubernetes StatefulSet: Deploy and manage MongoDB clusters on Kubernetes with persistent storage and replica sets.
- Docker: For containerization of MongoDB.
- Kubernetes (minikube or kubeadm): For orchestrating MongoDB clusters.
- Python 3.12.6: For running benchmark and test scripts.
- Atheris: For Coverage-guided fuzz testing in Python.
This project utilizes Docker and Kubernetes across a three-VM setup to automate the deployment, configuration, and testing of MongoDB clusters. Each VM is designated for specific roles to maximize efficiency, scalability, and reliability.
- Master node in Kubernetes. Deploys all pods.
- Runs Kubernetes pod that hosts the primary MongoDB replica set.
- Runs Kubernetes pod that hosts the secondary MongoDB replica set.
- Runs Kubernetes pod that runs a Python MongoDB client to interact with the MongoDB pods.
This VM distribution maximizes the project’s flexibility by leveraging Docker for containerized MongoDB deployments, and Kubernetes for high-availability and clustered management. This setup facilitates comprehensive testing of MongoDB across different environments, ensuring reliability, scalability, and performance.
- VM2:
192.168.5.211
(Control and Orchestration Node) - VM3:
192.168.5.68
(Primary MongoDB Replica Set) - VM4:
192.168.5.25
(Secondary MongoDB Replica Set + MongoDB Client)
git clone [email protected]:Pingumaniac/Unit_and_Fuzz_Testing_in_Evaluating_MongoDB_Reliability.git
cd Unit_and_Fuzz_Testing_in_Evaluating_MongoDB_Reliability
To install Docker on Linux, run
sudo bash install_docker.sh
To retrieve the MongoDB Docker container, run
sudo bash install_mongodb.sh
Next, run b-i on vm2
.
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.30/deploy/local-path-storage.yaml
kubectl apply -f mongo-service.yaml
kubectl get service
kubectl apply -f mongo-statefulset.yaml
kubectl get pods
kubectl exec -it mongo-0 -- mongo
rs.initiate({
"_id" : "rs0",
"members" : [
{
"_id" : 0,
"host" : "mongo-0.mongo.default.svc.cluster.local:27017",
},
{
"_id" : 1,
"host" : "mongo-1.mongo.default.svc.cluster.local:27017",
},
{
"_id" : 2,
"host" : "mongo-2.mongo.default.svc.cluster.local:27017",
}
]
})
kubectl exec -it mongo-[0|1|2] -- mongo
rs.status()
a. Login to Docker. To create an account or find your username and password, go here: https://app.docker.com/
docker login -u '<user> -p "<password>" docker.io
docker build -t <user>/pymongo:main .
docker image ls
docker push <user>/pymongo:main
kubectl apply -f pymongo-deployment.yaml
kubectl get pods -w
kubectl describe pod python-mongo-client
kubectl logs python-mongo-client
kubectl exec -it python-mongo-client -- /bin/bash
python3 test.py
python3 database_setup.py
pytest --cov=test_lib --cov-report=term-missing test_unit.py
python3 test_atheris.py -max_len=1024
python3 plot_metrics_unit.py
python3 plot_metrics_atheris.py
exit
- All users can view and report a bug in "GitHub Issues" of our repository.