anacostiaAI / anacostia-pipeline

Anacostia is a framework for creating machine learning operations (MLOps) pipelines
Apache License 2.0
2 stars 2 forks source link

Create testing environment #38

Closed mdo6180 closed 2 weeks ago

mdo6180 commented 4 months ago

Test outline:

  1. Use shell script to call docker compose and call the python file that creates dummy files for testing and puts the dummy files into the repositories mounted into the container running RootGraphService
  2. Docker compose spins up two containers
    • One container spins up a RootGraphService and the other container spins up a LeafGraphService.
    • RootGraphService contains metadata store node, monitoring resource node, and action node
    • LeafGraphService contains an action node.
  3. Test creates a few files, puts those files into the monitoring resource node, and checks to see if the action node on the RootGraphService and the LeafGraphService are both triggered.

Testing logging configurations

mdo6180 commented 2 months ago
mdo6180 commented 2 months ago

Created healthcheck by implementing healthcheck as python file. Python file call os._exit(status=0) to ensure script exits with status 0. Docker compose looks for exit status 0 from a shell command as passing condition for healthcheck.

mdo6180 commented 2 months ago

i'm going to stop using docker and docker compose because docker consumes too much memory (i literally ran out of ram to build the containers).

thus, i have decided to make the switch to bash scripts to set up the tests.

mdo6180 commented 2 months ago

the following code snippet is an example of how to assign IP addresses and ports to FastAPI servers using bash.

#!/bin/bash

# Define IP addresses and ports
IP1="192.168.100.1"
IP2="192.168.100.2"
PORT1="8001"
PORT2="8002"

# Create network namespaces
sudo ip netns add ns1
sudo ip netns add ns2

# Create veth pairs
sudo ip link add veth0 type veth peer name veth1
sudo ip link add veth2 type veth peer name veth3

# Assign one end of each veth pair to the respective namespace
sudo ip link set veth1 netns ns1
sudo ip link set veth3 netns ns2

# Assign IP addresses to the veth interfaces
sudo ip addr add $IP1/24 dev veth0
sudo ip netns exec ns1 ip addr add $IP1/24 dev veth1
sudo ip addr add $IP2/24 dev veth2
sudo ip netns exec ns2 ip addr add $IP2/24 dev veth3

# Bring up the interfaces
sudo ip link set veth0 up
sudo ip link set veth2 up
sudo ip netns exec ns1 ip link set veth1 up
sudo ip netns exec ns2 ip link set veth3 up

# Start FastAPI servers
# Run app1 in the first namespace
sudo ip netns exec ns1 uvicorn app1:app --host $IP1 --port $PORT1 &

# Run app2 in the second namespace
sudo ip netns exec ns2 uvicorn app2:app --host $IP2 --port $PORT2 &

# Output the completion message
echo "FastAPI servers are running at:"
echo "http://$IP1:$PORT1 (in namespace ns1)"
echo "http://$IP2:$PORT2 (in namespace ns2)"
mdo6180 commented 2 months ago
  • [ ] Create healthcheck in docker compose to know when root and leaf graph services are up and running (see 1 and 2)

    • [ ] Install curl or wget into the container first. (python:3.12.4-slim don't come with curl preinstalled)

no longer pursuing docker approach.