commit
526482de2a
7 changed files with 162 additions and 1 deletions
|
@ -1 +1 @@
|
|||
{"builds":[{"imageName":"gcr.io/lesser-weevil/emailservice","tag":"gcr.io/lesser-weevil/emailservice:v0.1.0-33-g6e6db3b@sha256:593de0cc94b95fa033838a3d3f3dc0168cc35f736b01ace2954b3648771e1027"},{"imageName":"gcr.io/lesser-weevil/productcatalogservice","tag":"gcr.io/lesser-weevil/productcatalogservice:v0.1.0-33-g6e6db3b@sha256:29dc89ac7aa66dcb70fd1c9e84f422a5e0c4bcb117ed0cb29c7cd6282ab13bbe"},{"imageName":"gcr.io/lesser-weevil/recommendationservice","tag":"gcr.io/lesser-weevil/recommendationservice:v0.1.0-33-g6e6db3b@sha256:de6cddba59ea40a879baf25b2ae58dd06b64532d0ca52dda4c4b6d22e577f0d6"},{"imageName":"gcr.io/lesser-weevil/shippingservice","tag":"gcr.io/lesser-weevil/shippingservice:v0.1.0-33-g6e6db3b@sha256:0ee734d45b10760c0d01bf3ca27a85b56296337adfe540f344860b2de1eb0277"},{"imageName":"gcr.io/lesser-weevil/checkoutservice","tag":"gcr.io/lesser-weevil/checkoutservice:v0.1.0-33-g6e6db3b@sha256:d9b7a695508b8df8d894d4b1ea24ebc8f651c069daab64df4acb2556c72ace1d"},{"imageName":"gcr.io/lesser-weevil/paymentservice","tag":"gcr.io/lesser-weevil/paymentservice:v0.1.0-33-g6e6db3b@sha256:93d422fe681b9ac2aed353b5b22f447dcd305bb297980edb0dfd68719e9dde65"},{"imageName":"gcr.io/lesser-weevil/currencyservice","tag":"gcr.io/lesser-weevil/currencyservice:v0.1.0-33-g6e6db3b@sha256:5dd9f85c65b0ab000f759ea37d78ff06643ea800220e9e34c251f3c1e33ab2b9"},{"imageName":"gcr.io/lesser-weevil/cartservice","tag":"gcr.io/lesser-weevil/cartservice:v0.1.0-33-g6e6db3b@sha256:6cc3baab0bdf2eda1ec9da076a102007c851a665c9fd8ee99d741c734c8a85fe"},{"imageName":"gcr.io/lesser-weevil/frontend","tag":"gcr.io/lesser-weevil/frontend:v0.1.0-33-g6e6db3b@sha256:43d6cbbfb02cb9a4435063c63127f1f4e22a8954f38cc78159c1ae7e44700bdd"},{"imageName":"gcr.io/lesser-weevil/loadgenerator","tag":"gcr.io/lesser-weevil/loadgenerator:v0.1.0-33-g6e6db3b@sha256:88ece337b51771e0a10cc09d8db31dd474d93fcbc47b145a9d9f6a27e24a5fb4"},{"imageName":"gcr.io/lesser-weevil/adservice","tag":"gcr.io/lesser-weevil/adservice:v0.1.0-33-g6e6db3b@sha256:dcb2c1644648b9c18c6fc48ad7fc1a15f4dc890ad3fca531b9892d6cfdf1a305"}]}
|
||||
{"builds":[{"imageName":"gcr.io/lesser-weevil/emailservice","tag":"gcr.io/lesser-weevil/emailservice:v0.1.0-49-g6c11f13@sha256:b5642298862ce0852e6038cf029ed75df6a08530c3ca9b86cd2ad4b50d5cff00"},{"imageName":"gcr.io/lesser-weevil/productcatalogservice","tag":"gcr.io/lesser-weevil/productcatalogservice:v0.1.0-49-g6c11f13@sha256:74288be0207731ee0f846273da3486638777cf8d4077bddd45e0aeac75bb3559"},{"imageName":"gcr.io/lesser-weevil/recommendationservice","tag":"gcr.io/lesser-weevil/recommendationservice:v0.1.0-49-g6c11f13-dirty@sha256:761fcf9065618d1edf9739c5a99e0b85e85a00ea79831d9cd14ceef281bfcb96"},{"imageName":"gcr.io/lesser-weevil/shippingservice","tag":"gcr.io/lesser-weevil/shippingservice:v0.1.0-49-g6c11f13@sha256:6625a1e45b63c32585248a51d32b1b5137c16c7fb0f622ee9efbd08ef0cfed42"},{"imageName":"gcr.io/lesser-weevil/checkoutservice","tag":"gcr.io/lesser-weevil/checkoutservice:v0.1.0-49-g6c11f13@sha256:cab8d517f524609837c7c70d357d7ba4aeb836dc417414d726079ed811928804"},{"imageName":"gcr.io/lesser-weevil/paymentservice","tag":"gcr.io/lesser-weevil/paymentservice:v0.1.0-49-g6c11f13@sha256:1d65c32c95fbf5fe7348e8d4975bf15a305279f78264f342734afc3d1273a7cb"},{"imageName":"gcr.io/lesser-weevil/currencyservice","tag":"gcr.io/lesser-weevil/currencyservice:v0.1.0-49-g6c11f13@sha256:dcbf4a09a2b7961ad00496c70ebb33b125d40b3a2c28e92dc18e44ad15ff9139"},{"imageName":"gcr.io/lesser-weevil/cartservice","tag":"gcr.io/lesser-weevil/cartservice:v0.1.0-49-g6c11f13@sha256:2d6b7b6422669a0850f3743c734d300cbcf247fe850127ea99f695e831e32374"},{"imageName":"gcr.io/lesser-weevil/frontend","tag":"gcr.io/lesser-weevil/frontend:v0.1.0-49-g6c11f13@sha256:119a11554f457f3a4df05672de4f51050f305fba67482b242543ec6fb4ed1f05"},{"imageName":"gcr.io/lesser-weevil/loadgenerator","tag":"gcr.io/lesser-weevil/loadgenerator:v0.1.0-49-g6c11f13@sha256:de90c5ce3bef7e118183a82b6a5de5f994045727b66462c2bffd4f57749f40c1"},{"imageName":"gcr.io/lesser-weevil/adservice","tag":"gcr.io/lesser-weevil/adservice:v0.1.0-49-g6c11f13@sha256:39a383bafca249864cd67a8eac66e67a19dc107b46566d7e16501c4f15ee0935"}]}
|
18
kubernetes-manifests/pinger.yaml
Normal file
18
kubernetes-manifests/pinger.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: pinger-job
|
||||
spec:
|
||||
schedule: "*/5 * * * *"
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: main
|
||||
image: pingjob
|
||||
env:
|
||||
- name: FRONTEND_ADDR
|
||||
value: "frontend:80"
|
||||
restartPolicy: OnFailure
|
||||
|
18
src/pingjob/Dockerfile
Normal file
18
src/pingjob/Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM python:3-slim as base
|
||||
|
||||
FROM base as builder
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
g++
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN pip install --install-option="--prefix=/install" -r requirements.txt
|
||||
|
||||
FROM base
|
||||
COPY --from=builder /install /usr/local
|
||||
|
||||
COPY . .
|
||||
ENTRYPOINT ["./pinger.sh"]
|
||||
|
86
src/pingjob/pinger.py
Normal file
86
src/pingjob/pinger.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2018 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import random
|
||||
|
||||
import requests
|
||||
import sys
|
||||
|
||||
BASE = sys.argv[1]
|
||||
|
||||
products = [
|
||||
'0PUK6V6EV0',
|
||||
'1YMWWN1N4O',
|
||||
'2ZYFJ3GM2N',
|
||||
'66VCHSJNUP',
|
||||
'6E92ZMYYFZ',
|
||||
'9SIQT8TOJO',
|
||||
'L9ECAV7KIM',
|
||||
'LS4PSXUNUM',
|
||||
'OLJCESPC7Z']
|
||||
|
||||
|
||||
def index():
|
||||
requests.get(BASE + "/")
|
||||
|
||||
|
||||
def setCurrency():
|
||||
currencies = ['EUR', 'USD', 'JPY', 'CAD']
|
||||
requests.post(BASE + "/setCurrency",
|
||||
{'currency_code': random.choice(currencies)})
|
||||
|
||||
|
||||
def browseProduct():
|
||||
requests.get(BASE + "/product/" + random.choice(products))
|
||||
|
||||
|
||||
def viewCart():
|
||||
requests.get(BASE + "/cart")
|
||||
|
||||
|
||||
def addToCart():
|
||||
product = random.choice(products)
|
||||
requests.get(BASE + "/product/" + product)
|
||||
requests.post(BASE + "/cart", {
|
||||
'product_id': product,
|
||||
'quantity': random.choice([1, 2, 3, 4, 5, 10])})
|
||||
|
||||
|
||||
def checkout():
|
||||
addToCart()
|
||||
requests.post(BASE + "/cart/checkout", {
|
||||
'email': 'someone@example.com',
|
||||
'street_address': '1600 Amphitheatre Parkway',
|
||||
'zip_code': '94043',
|
||||
'city': 'Mountain View',
|
||||
'state': 'CA',
|
||||
'country': 'United States',
|
||||
'credit_card_number': '4432-8015-6152-0454',
|
||||
'credit_card_expiration_month': '1',
|
||||
'credit_card_expiration_year': '2039',
|
||||
'credit_card_cvv': '672',
|
||||
})
|
||||
|
||||
|
||||
if not BASE:
|
||||
print("ERROR: no frontend address")
|
||||
else:
|
||||
print("pinging" + BASE)
|
||||
index()
|
||||
browseProduct()
|
||||
addToCart()
|
||||
viewCart()
|
||||
checkout()
|
27
src/pingjob/pinger.sh
Executable file
27
src/pingjob/pinger.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh -eu
|
||||
#
|
||||
# Copyright 2018 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#!/bin/bash
|
||||
set -e
|
||||
trap "exit" TERM
|
||||
|
||||
if [ -z "${FRONTEND_ADDR}" ]; then
|
||||
echo >&2 "FRONTEND_ADDR not specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
python pinger.py "${FRONTEND_ADDR}"
|
1
src/pingjob/requirements.in
Normal file
1
src/pingjob/requirements.in
Normal file
|
@ -0,0 +1 @@
|
|||
requests
|
11
src/pingjob/requirements.txt
Normal file
11
src/pingjob/requirements.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
#
|
||||
# pip-compile --output-file=requirements.txt requirements.in
|
||||
#
|
||||
certifi==2018.11.29 # via requests
|
||||
chardet==3.0.4 # via requests
|
||||
idna==2.8 # via requests
|
||||
requests==2.21.0
|
||||
urllib3==1.24.1 # via requests
|
Loading…
Add table
Add a link
Reference in a new issue