Skip to content

Commit

Permalink
Finalize Online Shop App
Browse files Browse the repository at this point in the history
Signed-off-by: David Schall <[email protected]>
  • Loading branch information
dhschall committed May 12, 2022
1 parent 28bea65 commit baf82c0
Show file tree
Hide file tree
Showing 139 changed files with 814 additions and 412 deletions.
1 change: 1 addition & 0 deletions .github/configs/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ matchers
maxVMNum
md
MECS
memcached
metadata
Metatrainer
metatrainer
Expand Down
101 changes: 56 additions & 45 deletions .github/workflows/e2e-online-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
push:
branches: [main]
paths:
- 'benchmarks/online_shop/*'
- 'benchmarks/online-shop/*'
- "utils/*"
- "tools/*"
- "runner/*"

pull_request:
branches: [main]
paths:
- 'benchmarks/online_shop/*'
- 'benchmarks/online-shop/*'
- "utils/*"
- "tools/*"
- "runner/*"
Expand All @@ -37,29 +37,20 @@ jobs:
lfs: "true"

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Set up Python version
uses: actions/setup-python@v3
with:
python-version: "3.8"
uses: docker/setup-buildx-action@v2

- name: Build and push
working-directory: benchmarks/online_shop/
working-directory: benchmarks/online-shop/
env:
GOPRIVATE_KEY: ${{ secrets.EASE_LAB_ACCESS_KEY }}
run: |
go get -u google.golang.org/protobuf/cmd/[email protected]
go get -u google.golang.org/grpc/cmd/[email protected]
chmod +x $(go env GOPATH)/bin/*
export PATH="$PATH:$(go env GOPATH)/bin"
make all
make push
Expand Down Expand Up @@ -90,17 +81,19 @@ jobs:
lfs: "true"

- name: start docker-compose benchmark
working-directory: benchmarks/online_shop/yamls/docker-compose
working-directory: benchmarks/online-shop/yamls/docker-compose
run: |
docker-compose -f ${{ matrix.file }} pull
docker-compose -f ${{ matrix.file }} up &> log_file &
sleep 60s
cat log_file
- name: invoke the chain
run: |
./tools/bin/grpcurl -plaintext -import-path ./tools/invoker/proto -proto helloworld.proto localhost:50000 helloworld.Greeter.SayHello
- name: show docker-compose log
run: cat benchmarks/online_shop/yamls/docker-compose/log_file
run: cat benchmarks/online-shop/yamls/docker-compose/log_file

test-knative:
name: Test Knative Deployment
Expand All @@ -111,20 +104,29 @@ jobs:
runs-on: [self-hosted, stock-knative]
strategy:
fail-fast: false
max-parallel: 1
max-parallel: 5
matrix:
service:
[
kn-adservice,
kn-cartservice,
kn-checkoutservice,
kn-currencyservice,
kn-emailservice,
kn-paymentservice,
kn-productcatalogservice,
kn-recommendationservice,
kn-shippingservice,
]
include:
- service: adservice
file: kn-adservice.yaml
- service: cartservice
file: kn-cartservice.yaml
database: yes
- service: checkoutservice
file: kn-checkoutservice.yaml
- service: currencyservice
file: kn-currencyservice.yaml
- service: emailservice
file: kn-emailservice.yaml
- service: paymentservice
file: kn-paymentservice.yaml
- service: productcatalogservice
file: kn-productcatalogservice.yaml
- service: recommendationservice
file: kn-recommendationservice.yaml
- service: shippingservice
file: kn-shippingservice.yaml

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -136,44 +138,53 @@ jobs:
with:
go-version: 1.16

- name: Deploy database if needed
working-directory: benchmarks
if: matrix.database == 'yes'
run: |
kubectl apply -f ./online-shop/yamls/knative/database.yaml
- name: Deploy knative
working-directory: benchmarks
run: kn service apply -f ./online_shop/yamls/knative/${{ matrix.service }}.yaml
run: |
kubectl apply -f ./online-shop/yamls/knative/${{ matrix.file }}
kubectl wait --for=condition=Ready -f ./online-shop/yamls/knative/${{ matrix.file }} --timeout 200s
- name: Check if service is ready
working-directory: benchmarks
run: |
sleep 5
kn service list
if [ "$( kn service list ${{ matrix.service }} | awk '{if (NR!=1) {print $9}}')" == "True" ] ;
then
echo Service ${{ matrix.service }} is running;
else
echo Service ${{ matrix.service }} is not ready.. wait 15 more seconds;
sleep 15
fi;
- name: Test invoking once
working-directory: tools/test-client
run: |
set -x
go build ./test-client.go
NODEPORT=$(kubectl get svc kourier-ingress -n kourier-system -o=jsonpath='{.spec.ports[0].nodePort}')
url_list=$(kn service list | awk '$2 ~ /http/ {sub(/http\:\/\//,""); print $2}')
for url in $url_list
do
./test-client -addr $url:$NODEPORT -name "Example text for Online Shop CI"
done
url=$(kn service describe ${{ matrix.service }} -o url | awk '$1 {sub(/http\:\/\//,""); print $1}')
./test-client --addr $url:$NODEPORT --name "Example text for Online Shop CI"
- name: Print logs
if: ${{ always() }}
run: |
set -x
container_list=$(kubectl get pods -n default -o jsonpath="{.items[*].spec.containers[*].name}")
container_list=$(kn service export ${{ matrix.service }} -o jsonpath="{.spec.service.spec.template.spec.containers[*].name}")
for container_name in $container_list
do
kubectl logs -n default -c $container_name -l serving.knative.dev/service=${{ matrix.service }}
done
- name: Down
if: ${{ always() }}
run: kn service delete --all --namespace default --wait

- name: Print logs from database
if: matrix.database == 'yes'
run: |
set -x
kubectl logs deployment/online-shop-database
- name: Down
working-directory: benchmarks
if: matrix.database == 'yes'
run: |
kubectl delete -f ./online-shop/yamls/knative/database.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- DISABLE_PROFILER=true
- DISABLE_DEBUGGER=true
- DISABLE_TRACING=true
- REDIS_ADDR=redis:6379
ports:
- target: 7070

Expand All @@ -29,4 +30,10 @@ services:
- --function-method=AddItem
ports:
- published: 50000
target: 50000
target: 50000

# Database
redis:
image: redis:alpine
ports:
- target: 6379
59 changes: 59 additions & 0 deletions benchmarks/online-shop/yamls/knative/database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# MIT License

# Copyright (c) 2022 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


## Database ----------
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: online-shop-database
namespace: default
spec:
selector:
matchLabels:
app: online-shop-database
template:
metadata:
labels:
app: online-shop-database
spec:
containers:
- name: databse
image: redis:alpine
ports:
- containerPort: 6379

---
apiVersion: v1
kind: Service
metadata:
name: online-shop-database
namespace: default
spec:
type: ClusterIP
selector:
app: online-shop-database
ports:
- name: database
port: 6379
targetPort: 6379
56 changes: 56 additions & 0 deletions benchmarks/online-shop/yamls/knative/kn-adservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# MIT License

# Copyright (c) 2022 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: adservice
namespace: default
spec:
template:
spec:
containers:
# Relay ---
- name: relay
image: docker.io/vhiveease/relay:latest
ports:
- name: h2c
containerPort: 50000
args:
- --addr=0.0.0.0:50000
- --function-endpoint-url=0.0.0.0
- --function-endpoint-port=9555
- --function-name=adservice
- --generator=unique
- --value=donuts
# Function ---
- name: function
image: docker.io/vhiveease/onlineshop-adservice:latest
env:
- name: PORT
value: "9555"
- name: DISABLE_TRACING
value: "1"
- name: DISABLE_PROFILER
value: "1"
- name: DISABLE_DEBUGGER
value: "1"
59 changes: 59 additions & 0 deletions benchmarks/online-shop/yamls/knative/kn-cartservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# MIT License

# Copyright (c) 2022 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: cartservice
namespace: default
spec:
template:
spec:
containers:
# Relay
- name: relay
image: docker.io/vhiveease/relay:latest
ports:
- name: h2c
containerPort: 50000
args:
- --addr=0.0.0.0:50000
- --function-endpoint-url=0.0.0.0
- --function-endpoint-port=7070
- --function-name=cartservice
- --generator=unique
- --value=12345
- --function-method=AddItem
# Function ---
- name: function
image: docker.io/vhiveease/onlineshop-cartservice:latest
env:
- name: PORT
value: "7070"
- name: DISABLE_TRACING
value: "1"
- name: DISABLE_PROFILER
value: "1"
- name: DISABLE_DEBUGGER
value: "1"
- name: REDIS_ADDR
value: "online-shop-database:6379"
Loading

0 comments on commit baf82c0

Please sign in to comment.