Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…book-store into main
  • Loading branch information
Adarsh Kolya committed Apr 6, 2021
2 parents 69d1df5 + 6a326d1 commit 34e0ecf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
51 changes: 13 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ World's smallest book store with a two-tier web design
* Brinda Murulidhara (32578418, bmurulidhara@umass.edu)

**Milestones**
- Milestone 1 - https://github.com/CS677-Labs/Lab-1-The_Bazaar/tree/milestone1

- Milestone 1 - https://github.com/CS677-Labs/Lab-2-Pygmy-The-book-store/tree/milestone1
- Milestone 2 - https://github.com/CS677-Labs/Lab-2-Pygmy-The-book-store/tree/milestone2

## Run testcases for Single server, single client usecase
```
Expand Down Expand Up @@ -36,51 +36,24 @@ bash test/MultiServerMultiClients.sh machines.txt
```

## Usage
### Running the servers on localhost
### Running the servers
```
pip install virtualenv
virtualenv .venv
```
#### Catalog server
```
#For linux based
source .venv/bin/activate
#For windows based
.venv/scripts/activate.bat
pip install -r src/catalog_server/requirements.txt
export FLASK_APP=src/catalog_server/views.py
python -m flask run --port 5000
```
### Order server
Open a new shell
```
cd LAB-2-PYGMY-THE-BOOK-STORE
#For linux based
source .venv/bin/activate
#For windows based
.venv/scripts/activate.bat
export FLASK_APP=src/order_server/order_server.py
python -m flask run --port 5001
pip install -r src/requirements.txt
```

### Frontend server
Open a new shell
### Setup the servers on either localhost or multiple machines
#### Create a txt file with any name and store three lines for the machine addresses for catalog, order and frontend servers respectively. For running the entire system on your localhost, use machines.txt.local.
```
cd LAB-2-PYGMY-THE-BOOK-STORE
#For linux based
source .venv/bin/activate
#For windows based
.venv/scripts/activate.bat
export FLASK_APP=src/frontend_server/frontend.py
python -m flask run --port 5002
bash run.sh machines.txt.local
```


### CLI
Open a new shell
```
Expand All @@ -94,17 +67,19 @@ cd src/cli
```
#### Lookup
```
python main.py lookup <item number>
python main.py --frontend_server <ip_of_frontend_server> lookup <item number>
```

--frontend_server is optional. If not provided, it takes localhost as default.

Example
```
python main.py lookup 1
python main.py --frontend_server ec2-35-175-129-185.compute-1.amazonaws.com lookup 1
```

#### Search
```
python main.py search --topic "<topic>"
python main.py --frontend_server <ip_of_frontend_server> search --topic "<topic>"
```

Example
Expand All @@ -114,7 +89,7 @@ python main.py search --topic "distributed systems"

#### Buy
```
python main.py buy <item number>
python main.py --frontend_server <ip_of_frontend_server> buy <item number>
```

Example
Expand Down
3 changes: 2 additions & 1 deletion test/MultiServersMultiClients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ echo "Test Case 6."
countBefore=$(echo $tmpoutput | sed -n 's/^.*count.:.//p' | awk -F[,}] '{print $1}')
echo "Current count of the - $countBefore"
echo "Attempting to buy this book twice concurrently."
python3 src/cli/main.py --frontend_server${machines[2]} buy 2 &
python3 src/cli/main.py --frontend_server ${machines[2]} buy 2 &
sleep 2
python3 src/cli/main.py --frontend_server ${machines[2]} buy 2 &
sleep 3
echo "Fetching the count after concurrent buys."
Expand Down
3 changes: 2 additions & 1 deletion test/SingleServerMultiClients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ countBefore=$(echo $tmpoutput | sed -n 's/^.*count.:.//p' | awk -F[,}] '{print $
echo "Current count of the - $countBefore"
echo "Attempting to buy this book twice concurrently."
python3 src/cli/main.py buy 2 &
sleep 2
python3 src/cli/main.py buy 2 &
sleep 5
sleep 3
echo "Fetching the count after concurrent buys."
tmpoutput=$(python3 src/cli/main.py lookup 2)
if [[ $tmpoutput == *"Failed"* ]] ; then
Expand Down

0 comments on commit 34e0ecf

Please sign in to comment.