commit
18a073eefa
43 changed files with 121 additions and 1150 deletions
12
.travis.yml
12
.travis.yml
|
@ -1,12 +0,0 @@
|
|||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
install:
|
||||
- curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v0.20.0/skaffold-linux-amd64
|
||||
- chmod +x skaffold
|
||||
- sudo mv skaffold /usr/local/bin
|
||||
|
||||
script:
|
||||
- skaffold build --profile travis-ci
|
|
@ -1,25 +0,0 @@
|
|||
# This configuration file is used to build and deploy the app into a
|
||||
# GKE cluster using Google Cloud Build.
|
||||
#
|
||||
# PREREQUISITES:
|
||||
# - Cloud Build service account must have role: "Kubernetes Engine Developer"
|
||||
|
||||
# USAGE:
|
||||
# GCP zone and GKE target cluster must be specified as substitutions
|
||||
# Example invocation:
|
||||
# `gcloud builds submit --config=cloudbuild.yaml --substitutions=_ZONE=us-central1-b,_CLUSTER=demo-app-staging .`
|
||||
|
||||
steps:
|
||||
- id: 'Deploy application to cluster'
|
||||
name: 'gcr.io/k8s-skaffold/skaffold:v0.20.0'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- >
|
||||
gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER;
|
||||
skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID;
|
||||
|
||||
# Add more power, and more time, for heavy Skaffold build
|
||||
timeout: '3600s'
|
||||
options:
|
||||
machineType: 'N1_HIGHCPU_8'
|
|
@ -1,44 +0,0 @@
|
|||
# Development Principles
|
||||
|
||||
> **Note:** This document outlines guidances behind some development decisions
|
||||
> behind the Hipster Shop demo application.
|
||||
|
||||
### Minimal configuration
|
||||
|
||||
Running the demo locally or on GCP should require minimal to no
|
||||
configuration unless absolutely necessary to run critical parts of the demo.
|
||||
|
||||
Configuration that takes multiple steps, especially such as creating service
|
||||
accounts should be avoided.
|
||||
|
||||
### App must work well outside GCP
|
||||
|
||||
Demo application should work reasonably well when it is not deployed to GCP
|
||||
services. The experience of running the application locally or on GCP should
|
||||
be close.
|
||||
|
||||
For example:
|
||||
- OpenCensus prints the traces to stdout when it cannot connect to GCP.
|
||||
- Stackdriver Debugging tries connecting to GCP multiple times, eventually gives
|
||||
up.
|
||||
|
||||
### Running on GCP must not reduce functionality
|
||||
|
||||
Running the demo on the GCP must not reduce/lose any of the capabilities
|
||||
developers have when running locally.
|
||||
|
||||
For example: Logs should still be printed to stdout/stderr even though logs are
|
||||
uploaded to Stackdriver Logging when on GCP, so that developers can use "kubectl
|
||||
logs" to diagnose each container.
|
||||
|
||||
### Microservice implementations should not be complex
|
||||
|
||||
Each service should provide a minimal implementation and try to avoid
|
||||
unnecessary code and logic that's not executed.
|
||||
|
||||
Keep in mind that any service implementation is a decent example of “a GRPC
|
||||
application that runs on Kubernetes”. Keeping the source code short and
|
||||
navigable will serve this purpose.
|
||||
|
||||
It is okay to have intentional inefficiencies in the code as they help
|
||||
illustrate the capabilities of profiling and diagnostics offerings.
|
|
@ -1,18 +0,0 @@
|
|||
## `hack/`
|
||||
|
||||
This directory provides scripts for building and pushing Docker images, and tagging new demo
|
||||
releases.
|
||||
|
||||
### env variables
|
||||
|
||||
- `TAG` - git release tag / Docker tag.
|
||||
- `REPO_PREFIX` - Docker repo prefix to push images. Format: `$user/$project`. Resulting images will be of the
|
||||
format `$user/$project/$svcname:$tag` (where `svcname` = `adservice`, `cartservice`,
|
||||
etc.)
|
||||
|
||||
### scripts
|
||||
|
||||
1. `./make-docker-images.sh`: builds and pushes images to the specified Docker repository.
|
||||
2. `./make-release-artifacts.sh`: generates a combined YAML file with image $TAG at:
|
||||
`./release/kubernetes-manifests/demo.yaml`.
|
||||
3. `./make-release.sh`: runs scripts 1 and 2, then runs `git tag` / pushes updated manifests to master.
|
|
@ -1,13 +0,0 @@
|
|||
# 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.
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 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.
|
||||
|
||||
# Builds and pushes docker image for each demo microservice.
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
log() { echo "$1" >&2; }
|
||||
|
||||
TAG="${TAG:?TAG env variable must be specified}"
|
||||
REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"
|
||||
|
||||
while IFS= read -d $'\0' -r dir; do
|
||||
# build image
|
||||
svcname="$(basename "${dir}")"
|
||||
image="${REPO_PREFIX}/$svcname:$TAG"
|
||||
(
|
||||
cd "${dir}"
|
||||
log "Building: ${image}"
|
||||
docker build -t "${image}" .
|
||||
|
||||
log "Pushing: ${image}"
|
||||
docker push "${image}"
|
||||
)
|
||||
done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0)
|
||||
|
||||
log "Successfully built and pushed all images."
|
|
@ -1,101 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 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.
|
||||
|
||||
# This script compiles manifest files with the image tags and places them in
|
||||
# /release/...
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
[[ -n "${DEBUG:-}" ]] && set -x
|
||||
|
||||
log() { echo "$1" >&2; }
|
||||
|
||||
TAG="${TAG:?TAG env variable must be specified}"
|
||||
REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"
|
||||
OUT_DIR="${OUT_DIR:-${SCRIPTDIR}/../release}"
|
||||
|
||||
print_license_header() {
|
||||
cat "${SCRIPTDIR}/license_header.txt"
|
||||
echo
|
||||
}
|
||||
|
||||
print_autogenerated_warning() {
|
||||
cat<<EOF
|
||||
# ----------------------------------------------------------
|
||||
# WARNING: This file is autogenerated. Do not manually edit.
|
||||
# ----------------------------------------------------------
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# define gsed as a function on Linux for compatibility
|
||||
[ "$(uname -s)" == "Linux" ] && gsed() {
|
||||
sed "$@"
|
||||
}
|
||||
|
||||
read_manifests() {
|
||||
local dir
|
||||
dir="$1"
|
||||
|
||||
while IFS= read -d $'\0' -r file; do
|
||||
# strip license headers (pattern "^# ")
|
||||
awk '
|
||||
/^[^# ]/ { found = 1 }
|
||||
found { print }' "${file}"
|
||||
|
||||
echo "---"
|
||||
done < <(find "${dir}" -name '*.yaml' -type f -print0)
|
||||
}
|
||||
|
||||
mk_kubernetes_manifests() {
|
||||
out_manifest="$(read_manifests "${SCRIPTDIR}/../kubernetes-manifests")"
|
||||
|
||||
# replace "image" repo, tag for each service
|
||||
for dir in ./src/*/
|
||||
do
|
||||
svcname="$(basename "${dir}")"
|
||||
image="$REPO_PREFIX/$svcname:$TAG"
|
||||
|
||||
pattern="^(\s*)image:\s.*$svcname(.*)(\s*)"
|
||||
replace="\1image: $image\3"
|
||||
out_manifest="$(gsed -r "s|$pattern|$replace|g" <(echo "${out_manifest}") )"
|
||||
done
|
||||
|
||||
print_license_header
|
||||
print_autogenerated_warning
|
||||
echo "${out_manifest}"
|
||||
}
|
||||
|
||||
mk_istio_manifests() {
|
||||
print_license_header
|
||||
print_autogenerated_warning
|
||||
read_manifests "${SCRIPTDIR}/../istio-manifests"
|
||||
}
|
||||
|
||||
main() {
|
||||
mkdir -p "${OUT_DIR}"
|
||||
local k8s_manifests_file istio_manifests_file
|
||||
|
||||
k8s_manifests_file="${OUT_DIR}/kubernetes-manifests.yaml"
|
||||
mk_kubernetes_manifests > "${k8s_manifests_file}"
|
||||
log "Written ${k8s_manifests_file}"
|
||||
|
||||
istio_manifests_file="${OUT_DIR}/istio-manifests.yaml"
|
||||
mk_istio_manifests > "${istio_manifests_file}"
|
||||
log "Written ${istio_manifests_file}"
|
||||
}
|
||||
|
||||
main
|
|
@ -1,51 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 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.
|
||||
|
||||
# This script creates a new release by:
|
||||
# - 1. building/pushing images
|
||||
# - 2. injecting tags into YAML manifests
|
||||
# - 3. creating a new git tag
|
||||
# - 4. pushing the tag/commit to master.
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
[[ -n "${DEBUG:-}" ]] && set -x
|
||||
|
||||
log() { echo "$1" >&2; }
|
||||
fail() { log "$1"; exit 1; }
|
||||
|
||||
TAG="${TAG:?TAG env variable must be specified}"
|
||||
REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified e.g. gcr.io\/google-samples\/microservices-demo}"
|
||||
|
||||
if [[ "$TAG" != v* ]]; then
|
||||
fail "\$TAG must start with 'v', e.g. v0.1.0 (got: $TAG)"
|
||||
fi
|
||||
|
||||
# build and push images
|
||||
"${SCRIPTDIR}"/make-docker-images.sh
|
||||
|
||||
# update yaml
|
||||
"${SCRIPTDIR}"/make-release-artifacts.sh
|
||||
|
||||
# create git release / push to master
|
||||
git add "${SCRIPTDIR}/../release/"
|
||||
git commit --allow-empty -m "Release $TAG"
|
||||
log "Pushing k8s manifests to master..."
|
||||
git tag "$TAG"
|
||||
git push --tags
|
||||
git push origin master
|
||||
|
||||
log "Successfully tagged release $TAG."
|
|
@ -1,44 +0,0 @@
|
|||
# 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.
|
||||
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: frontend-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use Istio default gateway implementation
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: frontend-ingress
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- frontend-gateway
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: frontend
|
||||
port:
|
||||
number: 80
|
|
@ -1,27 +0,0 @@
|
|||
# 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.
|
||||
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
hosts:
|
||||
- "frontend.default.svc.cluster.local"
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: frontend
|
||||
port:
|
||||
number: 80
|
|
@ -1,46 +0,0 @@
|
|||
# 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.
|
||||
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: whitelist-egress-googleapis
|
||||
spec:
|
||||
hosts:
|
||||
- "accounts.google.com" # Used to get token
|
||||
- "*.googleapis.com"
|
||||
ports:
|
||||
- number: 80
|
||||
protocol: HTTP
|
||||
name: http
|
||||
- number: 443
|
||||
protocol: HTTPS
|
||||
name: https
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: whitelist-egress-google-metadata
|
||||
spec:
|
||||
hosts:
|
||||
- metadata.google.internal
|
||||
addresses:
|
||||
- 169.254.169.254 # GCE metadata server
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
- number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: adservice
|
||||
image: gcr.io/google-samples/microservices-demo/adservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 9555
|
||||
env:
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: cartservice
|
||||
image: gcr.io/google-samples/microservices-demo/cartservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 7070
|
||||
env:
|
||||
|
|
|
@ -27,7 +27,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: checkoutservice
|
||||
image: gcr.io/google-samples/microservices-demo/checkoutservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 5050
|
||||
readinessProbe:
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: currencyservice
|
||||
image: gcr.io/google-samples/microservices-demo/currencyservice:v0.1.2
|
||||
ports:
|
||||
- name: grpc
|
||||
containerPort: 7000
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: emailservice
|
||||
image: gcr.io/google-samples/microservices-demo/emailservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
|
|
|
@ -27,7 +27,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: frontend
|
||||
image: gcr.io/google-samples/microservices-demo/frontend:v0.1.2
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
|
|
|
@ -41,7 +41,7 @@ spec:
|
|||
value: "frontend:80"
|
||||
containers:
|
||||
- name: main
|
||||
image: loadgenerator
|
||||
image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.2
|
||||
env:
|
||||
- name: FRONTEND_ADDR
|
||||
value: "frontend:80"
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: paymentservice
|
||||
image: gcr.io/google-samples/microservices-demo/paymentservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 50051
|
||||
env:
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: productcatalogservice
|
||||
image: gcr.io/google-samples/microservices-demo/productcatalogservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 3550
|
||||
env:
|
||||
|
|
|
@ -28,7 +28,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: recommendationservice
|
||||
image: gcr.io/google-samples/microservices-demo/recommendationservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
|
|
|
@ -27,7 +27,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: shippingservice
|
||||
image: gcr.io/google-samples/microservices-demo/shippingservice:v0.1.2
|
||||
ports:
|
||||
- containerPort: 50051
|
||||
env:
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
// ------------Ad service------------------
|
||||
|
||||
service AdService {
|
||||
rpc GetAds(AdRequest) returns (AdResponse) {}
|
||||
}
|
||||
|
||||
message AdRequest {
|
||||
// List of important key words from the current page describing the context.
|
||||
repeated string context_keys = 1;
|
||||
}
|
||||
|
||||
message AdResponse {
|
||||
repeated Ad ads = 1;
|
||||
}
|
||||
|
||||
message Ad {
|
||||
// url to redirect to when an ad is clicked.
|
||||
string redirect_url = 1;
|
||||
|
||||
// short advertisement text to display.
|
||||
string text = 2;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
// -----------------Cart service-----------------
|
||||
|
||||
service CartService {
|
||||
rpc AddItem(AddItemRequest) returns (Empty) {}
|
||||
rpc GetCart(GetCartRequest) returns (Cart) {}
|
||||
rpc EmptyCart(EmptyCartRequest) returns (Empty) {}
|
||||
}
|
||||
|
||||
message CartItem {
|
||||
string product_id = 1;
|
||||
int32 quantity = 2;
|
||||
}
|
||||
|
||||
message AddItemRequest {
|
||||
string user_id = 1;
|
||||
CartItem item = 2;
|
||||
}
|
||||
|
||||
message EmptyCartRequest {
|
||||
string user_id = 1;
|
||||
}
|
||||
|
||||
message GetCartRequest {
|
||||
string user_id = 1;
|
||||
}
|
||||
|
||||
message Cart {
|
||||
string user_id = 1;
|
||||
repeated CartItem items = 2;
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
// -------------Checkout service-----------------
|
||||
|
||||
service CheckoutService {
|
||||
rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {}
|
||||
}
|
||||
|
||||
message PlaceOrderRequest {
|
||||
string user_id = 1;
|
||||
string user_currency = 2;
|
||||
|
||||
Address address = 3;
|
||||
string email = 5;
|
||||
CreditCardInfo credit_card = 6;
|
||||
}
|
||||
|
||||
message PlaceOrderResponse {
|
||||
OrderResult order = 1;
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
// -----------------Currency service-----------------
|
||||
|
||||
service CurrencyService {
|
||||
rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {}
|
||||
rpc Convert(CurrencyConversionRequest) returns (Money) {}
|
||||
}
|
||||
|
||||
// Represents an amount of money with its currency type.
|
||||
message Money {
|
||||
// The 3-letter currency code defined in ISO 4217.
|
||||
string currency_code = 1;
|
||||
|
||||
// The whole units of the amount.
|
||||
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
|
||||
int64 units = 2;
|
||||
|
||||
// Number of nano (10^-9) units of the amount.
|
||||
// The value must be between -999,999,999 and +999,999,999 inclusive.
|
||||
// If `units` is positive, `nanos` must be positive or zero.
|
||||
// If `units` is zero, `nanos` can be positive, zero, or negative.
|
||||
// If `units` is negative, `nanos` must be negative or zero.
|
||||
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
|
||||
int32 nanos = 3;
|
||||
}
|
||||
|
||||
message GetSupportedCurrenciesResponse {
|
||||
// The 3-letter currency code defined in ISO 4217.
|
||||
repeated string currency_codes = 1;
|
||||
}
|
||||
|
||||
message CurrencyConversionRequest {
|
||||
Money from = 1;
|
||||
|
||||
// The 3-letter currency code defined in ISO 4217.
|
||||
string to_code = 2;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
// -------------Email service-----------------
|
||||
|
||||
service EmailService {
|
||||
rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {}
|
||||
}
|
||||
|
||||
message OrderItem {
|
||||
CartItem item = 1;
|
||||
Money cost = 2;
|
||||
}
|
||||
|
||||
message OrderResult {
|
||||
string order_id = 1;
|
||||
string shipping_tracking_id = 2;
|
||||
Money shipping_cost = 3;
|
||||
Address shipping_address = 4;
|
||||
repeated OrderItem items = 5;
|
||||
}
|
||||
|
||||
message SendOrderConfirmationRequest {
|
||||
string email = 1;
|
||||
OrderResult order = 2;
|
||||
}
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
// -------------Payment service-----------------
|
||||
|
||||
service PaymentService {
|
||||
rpc Charge(ChargeRequest) returns (ChargeResponse) {}
|
||||
}
|
||||
|
||||
message CreditCardInfo {
|
||||
string credit_card_number = 1;
|
||||
int32 credit_card_cvv = 2;
|
||||
int32 credit_card_expiration_year = 3;
|
||||
int32 credit_card_expiration_month = 4;
|
||||
}
|
||||
|
||||
message ChargeRequest {
|
||||
Money amount = 1;
|
||||
CreditCardInfo credit_card = 2;
|
||||
}
|
||||
|
||||
message ChargeResponse {
|
||||
string transaction_id = 1;
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
// ---------------Product Catalog----------------
|
||||
|
||||
service ProductCatalogService {
|
||||
rpc ListProducts(Empty) returns (ListProductsResponse) {}
|
||||
rpc GetProduct(GetProductRequest) returns (Product) {}
|
||||
rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {}
|
||||
}
|
||||
|
||||
// Represents an amount of money with its currency type.
|
||||
message Money {
|
||||
// The 3-letter currency code defined in ISO 4217.
|
||||
string currency_code = 1;
|
||||
|
||||
// The whole units of the amount.
|
||||
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
|
||||
int64 units = 2;
|
||||
|
||||
// Number of nano (10^-9) units of the amount.
|
||||
// The value must be between -999,999,999 and +999,999,999 inclusive.
|
||||
// If `units` is positive, `nanos` must be positive or zero.
|
||||
// If `units` is zero, `nanos` can be positive, zero, or negative.
|
||||
// If `units` is negative, `nanos` must be negative or zero.
|
||||
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
|
||||
int32 nanos = 3;
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
||||
message Product {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string description = 3;
|
||||
string picture = 4;
|
||||
Money price_usd = 5;
|
||||
|
||||
// Categories such as "vintage" or "gardening" that can be used to look up
|
||||
// other related products.
|
||||
repeated string categories = 6;
|
||||
}
|
||||
|
||||
message ListProductsResponse {
|
||||
repeated Product products = 1;
|
||||
}
|
||||
|
||||
message GetProductRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message SearchProductsRequest {
|
||||
string query = 1;
|
||||
}
|
||||
|
||||
message SearchProductsResponse {
|
||||
repeated Product results = 1;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
// ---------------Recommendation service----------
|
||||
|
||||
service RecommendationService {
|
||||
rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){}
|
||||
}
|
||||
|
||||
message ListRecommendationsRequest {
|
||||
string user_id = 1;
|
||||
repeated string product_ids = 2;
|
||||
}
|
||||
|
||||
message ListRecommendationsResponse {
|
||||
repeated string product_ids = 1;
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package hipstershop;
|
||||
|
||||
|
||||
|
||||
// ---------------Shipping Service----------
|
||||
|
||||
service ShippingService {
|
||||
rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {}
|
||||
rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {}
|
||||
}
|
||||
|
||||
message GetQuoteRequest {
|
||||
Address address = 1;
|
||||
repeated CartItem items = 2;
|
||||
}
|
||||
|
||||
message GetQuoteResponse {
|
||||
Money cost_usd = 1;
|
||||
}
|
||||
|
||||
message ShipOrderRequest {
|
||||
Address address = 1;
|
||||
repeated CartItem items = 2;
|
||||
}
|
||||
|
||||
message ShipOrderResponse {
|
||||
string tracking_id = 1;
|
||||
}
|
||||
|
||||
message Address {
|
||||
string street_address = 1;
|
||||
string city = 2;
|
||||
string state = 3;
|
||||
string country = 4;
|
||||
int32 zip_code = 5;
|
||||
}
|
||||
|
||||
|
||||
// Represents an amount of money with its currency type.
|
||||
message Money {
|
||||
// The 3-letter currency code defined in ISO 4217.
|
||||
string currency_code = 1;
|
||||
|
||||
// The whole units of the amount.
|
||||
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
|
||||
int64 units = 2;
|
||||
|
||||
// Number of nano (10^-9) units of the amount.
|
||||
// The value must be between -999,999,999 and +999,999,999 inclusive.
|
||||
// If `units` is positive, `nanos` must be positive or zero.
|
||||
// If `units` is zero, `nanos` can be positive, zero, or negative.
|
||||
// If `units` is negative, `nanos` must be negative or zero.
|
||||
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
|
||||
int32 nanos = 3;
|
||||
}
|
||||
|
||||
message CartItem {
|
||||
string product_id = 1;
|
||||
int32 quantity = 2;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
# 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.
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# WARNING: This file is autogenerated. Do not manually edit.
|
||||
# ----------------------------------------------------------
|
||||
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: frontend-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use Istio default gateway implementation
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: frontend-ingress
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- frontend-gateway
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: frontend
|
||||
port:
|
||||
number: 80
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
hosts:
|
||||
- "frontend.default.svc.cluster.local"
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: frontend
|
||||
port:
|
||||
number: 80
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: whitelist-egress-googleapis
|
||||
spec:
|
||||
hosts:
|
||||
- "accounts.google.com" # Used to get token
|
||||
- "*.googleapis.com"
|
||||
ports:
|
||||
- number: 80
|
||||
protocol: HTTP
|
||||
name: http
|
||||
- number: 443
|
||||
protocol: HTTPS
|
||||
name: https
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: whitelist-egress-google-metadata
|
||||
spec:
|
||||
hosts:
|
||||
- metadata.google.internal
|
||||
addresses:
|
||||
- 169.254.169.254 # GCE metadata server
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
- number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
---
|
27
scripts/setup.bat
Normal file
27
scripts/setup.bat
Normal file
|
@ -0,0 +1,27 @@
|
|||
# other k8s artifacts
|
||||
kubectl apply -f ./kubernetes-manifests/emailservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/frontend.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/loadgenerator.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/paymentservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/recommendationservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/redis.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/shippingservice.yaml
|
||||
|
||||
# ballerina service k8s artifacts
|
||||
kubectl apply -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina
|
||||
|
||||
# challenges
|
||||
kubectl apply -f ./kubernetes-manifests/currencyservice.yaml
|
||||
# kubectl apply -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/productcatalogservice.yaml
|
||||
# kubectl apply -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/cartservice.yaml
|
||||
# kubectl apply -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/adservice.yaml
|
||||
# kubectl apply -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/checkoutservice.yaml
|
||||
# kubectl apply -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina
|
29
scripts/setup.sh
Normal file
29
scripts/setup.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
# other k8s artifacts
|
||||
kubectl apply -f ./kubernetes-manifests/emailservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/frontend.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/loadgenerator.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/paymentservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/recommendationservice.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/redis.yaml
|
||||
kubectl apply -f ./kubernetes-manifests/shippingservice.yaml
|
||||
|
||||
# ballerina service k8s artifacts
|
||||
kubectl apply -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina
|
||||
|
||||
# challenges
|
||||
kubectl apply -f ./kubernetes-manifests/currencyservice.yaml
|
||||
# kubectl apply -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/productcatalogservice.yaml
|
||||
#kubectl apply -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/cartservice.yaml
|
||||
# kubectl apply -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/adservice.yaml
|
||||
# kubectl apply -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina
|
||||
|
||||
kubectl apply -f ./kubernetes-manifests/checkoutservice.yaml
|
||||
# kubectl apply -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina
|
||||
|
||||
|
27
scripts/shutdown.bat
Normal file
27
scripts/shutdown.bat
Normal file
|
@ -0,0 +1,27 @@
|
|||
#other k8s artifacts
|
||||
kubectl delete -f ./kubernetes-manifests/emailservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/frontend.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/loadgenerator.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/paymentservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/recommendationservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/redis.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/shippingservice.yaml
|
||||
|
||||
#ballerina service k8s artifacts
|
||||
kubectl delete -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina
|
||||
|
||||
#challenges
|
||||
kubectl delete -f ./kubernetes-manifests/currencyservice.yaml
|
||||
# kubectl delete -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/productcatalogservice.yaml
|
||||
#kubectl delete -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/cartservice.yaml
|
||||
# kubectl delete -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/adservice.yaml
|
||||
# kubectl delete -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/checkoutservice.yaml
|
||||
# kubectl delete -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina
|
27
scripts/shutdown.sh
Normal file
27
scripts/shutdown.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#other k8s artifacts
|
||||
kubectl delete -f ./kubernetes-manifests/emailservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/frontend.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/loadgenerator.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/paymentservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/recommendationservice.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/redis.yaml
|
||||
kubectl delete -f ./kubernetes-manifests/shippingservice.yaml
|
||||
|
||||
#ballerina service k8s artifacts
|
||||
kubectl delete -f ./src/recommendationservice_ballerina/target/kubernetes/recommendationservice_ballerina
|
||||
|
||||
#challenges
|
||||
kubectl delete -f ./kubernetes-manifests/currencyservice.yaml
|
||||
# kubectl delete -f ./src/currencyservice_ballerina/target/kubernetes/currencyservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/productcatalogservice.yaml
|
||||
#kubectl delete -f ./src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/cartservice.yaml
|
||||
# kubectl delete -f ./src/cartservice_ballerina/target/kubernetes/cartservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/adservice.yaml
|
||||
# kubectl delete -f ./src/adservice_ballerina/target/kubernetes/adservice_ballerina
|
||||
|
||||
kubectl delete -f ./kubernetes-manifests/checkoutservice.yaml
|
||||
# kubectl delete -f ./src/checkoutservice_ballerina/target/kubernetes/checkoutservice_ballerina
|
44
setup.sh
44
setup.sh
|
@ -1,44 +0,0 @@
|
|||
kubectl apply -f HipsterShop/target/kubernetes/paymentservice
|
||||
kubectl apply -f HipsterShop/target/kubernetes/shippingservice
|
||||
kubectl apply -f HipsterShop/target/kubernetes/emailservice
|
||||
kubectl apply -f k8s_manifests/frontend/frontend-kubernetes-manifests.yaml
|
||||
|
||||
ballerina build --sourceroot src/recommendationservice_ballerina --all --skip-tests
|
||||
kubectl apply -f src/recommendationservice/target/kubernetes/recommendationservice
|
||||
|
||||
# Cart service
|
||||
kubectl apply -f HipsterShop/target/kubernetes/adservice
|
||||
# Replace above command with following command when you implemented the ad service in Ballerina.
|
||||
|
||||
# ballerina build --sourceroot src/adservice_ballerina --all --skip-tests
|
||||
# kubectl apply -f src/adservice_ballerina/target/kubernetes/adservice
|
||||
|
||||
kubectl apply -f HipsterShop/target/kubernetes/currencyservice
|
||||
# Replace above command with following command when you implemented the currency service in Ballerina.
|
||||
|
||||
# ballerina build --sourceroot src/currencyservice_ballerina --all --skip-tests
|
||||
# kubectl apply -f src/currencyservice_ballerina/target/kubernetes/currencyservice
|
||||
|
||||
# Cart service
|
||||
kubectl apply -f HipsterShop/target/kubernetes/cartservice
|
||||
# Replace above command with following command when you implemented the cart service in Ballerina.
|
||||
|
||||
# ballerina build --sourceroot src/cartservice_ballerina --all --skip-tests
|
||||
# kubectl apply -f src/cartservice_ballerina/target/kubernetes/cartservice
|
||||
|
||||
# Product Catalog Service
|
||||
kubectl apply -f HipsterShop/target/kubernetes/productcatalogservice
|
||||
|
||||
# Replace above with following command when you implemented the product catalog service in Ballerina.
|
||||
|
||||
# ballerina build --sourceroot src/productcatalogservice_ballerina --all --skip-tests
|
||||
# kubectl apply -f src/productcatalogservice_ballerina/target/kubernetes/productcatalogservice
|
||||
|
||||
# Checkout service
|
||||
kubectl apply -f HipsterShop/target/kubernetes/checkoutservice
|
||||
# Replace above with following command when you implemented the checkout service in Ballerina.
|
||||
|
||||
# ballerina build --sourceroot src/checkoutservice_ballerina --all --skip-tests
|
||||
# kubectl apply -f src/checkoutservice_ballerina/target/kubernetes/checkoutservice
|
||||
|
||||
kubectl get services
|
|
@ -1,71 +0,0 @@
|
|||
# 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.
|
||||
|
||||
apiVersion: skaffold/v1beta2
|
||||
kind: Config
|
||||
build:
|
||||
artifacts:
|
||||
# image tags are relative; to specify an image repo (e.g. GCR), you
|
||||
# must provide a "default repo" using one of the methods described
|
||||
# here:
|
||||
# https://skaffold.dev/docs/concepts/#image-repository-handling
|
||||
- image: emailservice
|
||||
context: src/emailservice
|
||||
- image: productcatalogservice
|
||||
context: src/productcatalogservice
|
||||
- image: recommendationservice
|
||||
context: src/recommendationservice
|
||||
- image: shippingservice
|
||||
context: src/shippingservice
|
||||
- image: checkoutservice
|
||||
context: src/checkoutservice
|
||||
- image: paymentservice
|
||||
context: src/paymentservice
|
||||
- image: currencyservice
|
||||
context: src/currencyservice
|
||||
- image: cartservice
|
||||
context: src/cartservice
|
||||
- image: frontend
|
||||
context: src/frontend
|
||||
- image: loadgenerator
|
||||
context: src/loadgenerator
|
||||
- image: adservice
|
||||
context: src/adservice
|
||||
tagPolicy:
|
||||
gitCommit: {}
|
||||
deploy:
|
||||
kubectl:
|
||||
manifests:
|
||||
- ./kubernetes-manifests/**.yaml
|
||||
profiles:
|
||||
# "travis-ci" profile is used to build the images without
|
||||
# pushing them.
|
||||
- name: travis-ci
|
||||
build:
|
||||
local:
|
||||
push: false
|
||||
# "gcb" profile allows building and pushing the images
|
||||
# on Google Container Builder without requiring docker
|
||||
# installed on the developer machine. However, note that
|
||||
# since GCB does not cache the builds, each build will
|
||||
# start from scratch and therefore take a long time.
|
||||
#
|
||||
# This is not used by default. To use it, run:
|
||||
# skaffold run -p gcb
|
||||
- name: gcb
|
||||
build:
|
||||
googleCloudBuild:
|
||||
diskSizeGb: 300
|
||||
machineType: N1_HIGHCPU_32
|
||||
timeout: 4000s
|
3
tests/cartservice/.gitignore
vendored
3
tests/cartservice/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
/bin/*
|
||||
/obj/*
|
||||
/.vs/*
|
|
@ -1,136 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Grpc.Core;
|
||||
using Hipstershop;
|
||||
using Xunit;
|
||||
using static Hipstershop.CartService;
|
||||
|
||||
namespace cartservice
|
||||
{
|
||||
public class E2ETests
|
||||
{
|
||||
private static string serverHostName = "localhost";
|
||||
private static int port = 7070;
|
||||
|
||||
[Fact]
|
||||
public async Task GetItem_NoAddItemBefore_EmptyCartReturned()
|
||||
{
|
||||
string userId = Guid.NewGuid().ToString();
|
||||
|
||||
// Construct server's Uri
|
||||
string targetUri = $"{serverHostName}:{port}";
|
||||
|
||||
// Create a GRPC communication channel between the client and the server
|
||||
var channel = new Channel(targetUri, ChannelCredentials.Insecure);
|
||||
|
||||
var client = new CartServiceClient(channel);
|
||||
|
||||
var request = new GetCartRequest
|
||||
{
|
||||
UserId = userId,
|
||||
};
|
||||
|
||||
var cart = await client.GetCartAsync(request);
|
||||
Assert.NotNull(cart);
|
||||
|
||||
// All grpc objects implement IEquitable, so we can compare equality with by-value semantics
|
||||
Assert.Equal(new Cart(), cart);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddItem_ItemExists_Updated()
|
||||
{
|
||||
string userId = Guid.NewGuid().ToString();
|
||||
|
||||
// Construct server's Uri
|
||||
string targetUri = $"{serverHostName}:{port}";
|
||||
|
||||
// Create a GRPC communication channel between the client and the server
|
||||
var channel = new Channel(targetUri, ChannelCredentials.Insecure);
|
||||
|
||||
var client = new CartServiceClient(channel);
|
||||
var request = new AddItemRequest
|
||||
{
|
||||
UserId = userId,
|
||||
Item = new CartItem
|
||||
{
|
||||
ProductId = "1",
|
||||
Quantity = 1
|
||||
}
|
||||
};
|
||||
|
||||
// First add - nothing should fail
|
||||
await client.AddItemAsync(request);
|
||||
|
||||
// Second add of existing product - quantity should be updated
|
||||
await client.AddItemAsync(request);
|
||||
|
||||
var getCartRequest = new GetCartRequest
|
||||
{
|
||||
UserId = userId
|
||||
};
|
||||
var cart = await client.GetCartAsync(getCartRequest);
|
||||
Assert.NotNull(cart);
|
||||
Assert.Equal(userId, cart.UserId);
|
||||
Assert.Single(cart.Items);
|
||||
Assert.Equal(2, cart.Items[0].Quantity);
|
||||
|
||||
// Cleanup
|
||||
await client.EmptyCartAsync(new EmptyCartRequest{ UserId = userId });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddItem_New_Inserted()
|
||||
{
|
||||
string userId = Guid.NewGuid().ToString();
|
||||
|
||||
// Construct server's Uri
|
||||
string targetUri = $"{serverHostName}:{port}";
|
||||
|
||||
// Create a GRPC communication channel between the client and the server
|
||||
var channel = new Channel(targetUri, ChannelCredentials.Insecure);
|
||||
|
||||
// Create a proxy object to work with the server
|
||||
var client = new CartServiceClient(channel);
|
||||
|
||||
var request = new AddItemRequest
|
||||
{
|
||||
UserId = userId,
|
||||
Item = new CartItem
|
||||
{
|
||||
ProductId = "1",
|
||||
Quantity = 1
|
||||
}
|
||||
};
|
||||
|
||||
await client.AddItemAsync(request);
|
||||
|
||||
var getCartRequest = new GetCartRequest
|
||||
{
|
||||
UserId = userId
|
||||
};
|
||||
var cart = await client.GetCartAsync(getCartRequest);
|
||||
Assert.NotNull(cart);
|
||||
Assert.Equal(userId, cart.UserId);
|
||||
Assert.Single(cart.Items);
|
||||
|
||||
await client.EmptyCartAsync(new EmptyCartRequest{ UserId = userId });
|
||||
cart = await client.GetCartAsync(getCartRequest);
|
||||
Assert.Empty(cart.Items);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.0" />
|
||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.6.0" />
|
||||
<PackageReference Include="Grpc" Version="1.12.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\cartservice\cartservice.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue