Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d22d9b2
Adding locust chart
natarajaya Aug 18, 2018
c5ee411
Adding basic GPII locust tasks
natarajaya Aug 18, 2018
e8ab297
Adding locust modules
natarajaya Aug 18, 2018
28e3df9
Various fixes
natarajaya Aug 19, 2018
8a8c966
locust_workers should be configurable
natarajaya Aug 19, 2018
eafdd07
Adding locust/tasks into .gitignore
natarajaya Aug 20, 2018
db27bb7
Link tasks before applying chart, customizable locust scripts, check …
natarajaya Aug 20, 2018
cc35eca
Use EXIT_STATUS
natarajaya Aug 20, 2018
919d4dd
Merge branch 'master' of github.com:gpii-ops/gpii-infra into locust
natarajaya Aug 21, 2018
cd8c89a
Small fixes
natarajaya Aug 21, 2018
78b558a
Remove tasks from locust chart before creating links
natarajaya Aug 21, 2018
2886528
Cleanup links after chart install, run swarm on every apply
natarajaya Aug 21, 2018
da38a0b
Don't need quotes here
natarajaya Aug 21, 2018
fa5df5e
Merge branch 'master' of github.com:gpii-ops/gpii-infra into locust
natarajaya Aug 23, 2018
a047c42
Merge branch 'master' of github.com:gpii-ops/gpii-infra into locust
natarajaya Aug 23, 2018
6f3e497
Various fixes
natarajaya Aug 23, 2018
bcc20cd
Sleep more between retries
natarajaya Aug 23, 2018
8f8253b
Cosmetic tasks update
natarajaya Aug 23, 2018
602a11d
Use greater equal
natarajaya Aug 24, 2018
9bc8d31
Do not use greater equal, use less than
natarajaya Aug 24, 2018
8f9f482
Tweak some variables
natarajaya Aug 24, 2018
2134037
Add flowmanager tasks
natarajaya Aug 28, 2018
05e108a
Set TF_VAR_domain_name in vars.rb
natarajaya Aug 28, 2018
5d307a3
Use domain_name instead of parsing dns_zones in flowmanager,preferences
natarajaya Aug 28, 2018
9040090
Various fixes
natarajaya Aug 28, 2018
a034305
Add smoke tests to gcp-dev stage of CI config
natarajaya Aug 28, 2018
be12350
Merge branch 'master' of github.com:gpii-ops/gpii-infra into locust
natarajaya Aug 29, 2018
1f6d9ab
Use snake case for task naming
natarajaya Aug 29, 2018
9d2f465
Rename var, exit if swarm_duration empty
natarajaya Aug 29, 2018
58fbbe1
Tweak some more vars
natarajaya Aug 29, 2018
ae3af4f
Add test.rake
natarajaya Aug 29, 2018
2867b89
Update .gitlab-ci.yml
natarajaya Aug 30, 2018
a422859
Bump flowmanager mrt
natarajaya Aug 30, 2018
de6dd99
No need to destroy locust module
natarajaya Aug 30, 2018
344b4fd
Destroy module and sleep before running tests, tweak flowmanager thre…
natarajaya Aug 30, 2018
7e45220
Rearrange entries, add test steps to gcp-stg, gcp-prd
natarajaya Aug 30, 2018
b7bf75c
Bumping preferences mrt to 4000 due to GPII-3250
natarajaya Aug 31, 2018
b63c9f6
Add comment
natarajaya Aug 31, 2018
9950012
Bump preferences mrt
natarajaya Aug 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gcp/live/*/compose.env
gcp/live/*/*secrets/**
gcp/live/*/*values/**
common/live/*/*secrets/**
common/charts/locust/tasks/*
aws/modules/deploy/secrets/*-secrets.yml
aws/prereqs/dev/terraform.tfstate*
tags
Expand Down
26 changes: 18 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ gcp-dev:
- rake clobber
- rake configure_serviceaccount_ci_restore
- rake
- rake test_preferences
- rake test_flowmanager
after_script:
# Clean up even if something failed.
- cd gcp/live/dev
Expand Down Expand Up @@ -120,28 +122,32 @@ aws-stg:
stage: stg
tags:
- aws
environment:
name: stg
script:
- cd aws/stg
- rake clobber
- rake
environment:
name: stg

# DISABLED while we sort out the gcp-stg -> gcp-gpii-stg migration.
.gcp-stg:
stage: stg
tags:
- gcp
environment:
name: stg
script:
- cd gcp/live/stg
- rake clobber
- rake configure_serviceaccount_ci_restore
- rake
environment:
name: stg
- rake test_preferences
- rake test_flowmanager
after_script:
# Clean up even if something failed.
- cd gcp/live/stg
# Destroy Locust module (used for smoke tests)
- rake destroy_module[locust]
# Remove all SA keys except current one to prevent hitting 10 keys per SA limit (GPII-3299)
- rake destroy_sa_keys

Expand Down Expand Up @@ -182,12 +188,12 @@ aws-prd:
RAKE_REALLY_RUN_IN_PRD: "true"
tags:
- aws
environment:
name: prd
script:
- cd aws/prd
- rake clobber
- rake
environment:
name: prd

# DISABLED while we sort out the gcp-stg -> gcp-gpii-stg migration.
.gcp-prd:
Expand All @@ -196,15 +202,19 @@ aws-prd:
RAKE_REALLY_RUN_IN_PRD: "true"
tags:
- gcp
environment:
name: prd
script:
- cd gcp/live/prd
- rake clobber
- rake configure_serviceaccount_ci_restore
- rake
environment:
name: prd
- rake test_preferences
- rake test_flowmanager
after_script:
# Clean up even if something failed.
- cd gcp/live/prd
# Destroy Locust module (used for smoke tests)
- rake destroy_module[locust]
# Remove all SA keys except current one to prevent hitting 10 keys per SA limit (GPII-3299)
- rake destroy_sa_keys
11 changes: 11 additions & 0 deletions common/charts/locust/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: locust
description: A modern load testing framework
version: 0.3.0
appVersion: 0.7.5
maintainers:
- name: so0k
email: vincent.drl@gmail.com
home: http://locust.io
icon: https://pbs.twimg.com/profile_images/1867636195/locust-logo-orignal.png
sources:
- https://github.com/honestbee/distributed-load-testing
73 changes: 73 additions & 0 deletions common/charts/locust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Locust Helm Chart

This is a templated deployment of [Locust](http://locust.io) for Distributed Load
testing using Kubernetes.

## Pre Requisites:

* Requires (and tested with) helm `v2.1.2` or above.

## Chart details

This chart will do the following:

* Convert all files in `tasks/` folder into a configmap
* Create a Locust master and Locust worker deployment with the Target host
and Tasks file specified.


### Installing the chart

To install the chart with the release name `locust-nymph` in the default namespace:

```bash
helm install -n locust-nymph --set master.config.target-host=http://site.example.com stable/locust
```

| Parameter | Description | Default |
| ---------------------------- | ---------------------------------- | ----------------------------------------------------- |
| `Name` | Locust master name | `locust` |
| `image.repository` | Locust container image name | `quay.io/honestbee/locust` |
| `image.tag` | Locust Container image tag | `0.7.5` |
| `image.pullSecrets` | Locust Container image registry secret | `None` |
| `service.type` | k8s service type exposing master | `NodePort` |
| `service.nodePort` | Port on cluster to expose master | `0` |
| `service.annotations` | KV containing custom annotations | `{}` |
| `service.extraLabels` | KV containing extra labels | `{}` |
| `master.config.target-host` | locust target host | `http://site.example.com` |
| `worker.config.locust-script`| locust script to run | `/locust-tasks/tasks.py` |
| `worker.replicaCount` | Number of workers to run | `2` |

Specify parameters using `--set key=value[,key=value]` argument to `helm install`

Alternatively a YAML file that specifies the values for the parameters can be provided like this:

```bash
$ helm install --name my-release -f values.yaml stable/locust
```

You can start the swarm from the command line using Port forwarding as follows:

Get the Locust URL following the Post Installation notes.

for example:
```bash
export LOCUST_URL=http://127.0.0.1:8089
```

Start / Monitor & Stop the Locust swarm via the web panel or with following commands:

Start:
```bash
curl -XPOST $LOCUST_URL/swarm -d"locust_count=100&hatch_rate=10"
```

Monitor:
```bash
watch -n 1 "curl -s $LOCUST_URL/stats/requests | jq -r '[.user_count, .total_rps, .state] | @tsv'"
```

Stop:
```bash
curl $LOCUST_URL/stop
```
24 changes: 24 additions & 0 deletions common/charts/locust/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ .Chart.Name }} installed!

Get the Locust URL to visit by running these commands in the same shell:

{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get svc -n {{ .Release.Namespace }} {{ template "locust.master-svc" . }} -o jsonpath='{.spec.ports[?(@.name=="{{ .Values.service.name }}")].nodePort}')
export NODE_IP=$(kubectl get no -o jsonpath="{.items[0].status.addresses[0].address}")
export LOCUST_URL=http://$NODE_IP:$NODE_PORT/

{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl get svc -n {{ .Release.Namespace }} -w {{ template "locust.master-svc" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "locust.master-svc" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
export LOCUST_URL=http://$SERVICE_IP:{{ .Values.service.externalPort }}/

{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get po --namespace {{ .Release.Namespace }} -l "app={{ template "locust.fullname" . }},component=master" -o jsonpath="{.items[0].metadata.name}")
export LOCUST_URL=http://127.0.0.1:{{ .Values.service.externalPort }}
kubectl port-forward $POD_NAME {{ .Values.service.externalPort }}:{{ .Values.service.externalPort }} &

{{- end }}

For more information on Distributed load testing on Kubernetes using Locust, visit:
https://cloud.google.com/solutions/distributed-load-testing-using-kubernetes
27 changes: 27 additions & 0 deletions common/charts/locust/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "locust.fullname" -}}
{{- printf "%s-%s" .Release.Name "locust" | trunc 63 -}}
{{- end -}}

{{- define "locust.master-svc" -}}
{{- printf "%s-%s" .Release.Name "master-svc" | trunc 63 -}}
{{- end -}}

{{- define "locust.master" -}}
{{- printf "%s-%s" .Release.Name "master" | trunc 63 -}}
{{- end -}}

{{- define "locust.worker" -}}
{{- printf "%s-%s" .Release.Name "worker" | trunc 63 -}}
{{- end -}}

{{/*
Create fully qualified configmap name.
*/}}
{{- define "locust.worker-configmap" -}}
{{- printf "%s-%s" .Release.Name "worker" -}}
{{- end -}}
71 changes: 71 additions & 0 deletions common/charts/locust/templates/master-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "locust.master" . }}
labels:
app: {{ template "locust.fullname" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
component: master
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: {{ default 1 .Values.master.maxSurge }}
maxUnavailable: {{ default 1 .Values.master.maxUnavailable }}
template:
metadata:
labels:
release: {{ .Release.Name | quote }}
app: {{ template "locust.fullname" . }}
component: "master"
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.image.pullSecrets | indent 8 }}
{{- end }}
containers:
- name: locust
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{ toYaml .Values.worker.resources | indent 10 }}
env:
{{- range $key, $value := .Values.master.config }}
- name: {{ $key | upper | replace "-" "_" }}
value: {{ $value | quote }}
{{- end }}
- name: LOCUST_MODE
value: "master"
- name: LOCUST_SCRIPT
value: {{ index .Values.worker.config "locust-script" | quote }}
ports:
- containerPort: {{ .Values.service.internalPort }}
name: loc-master-web
protocol: TCP
- containerPort: 5557
name: loc-master-p1
protocol: TCP
- containerPort: 5558
name: loc-master-p2
protocol: TCP
volumeMounts:
- name: locust-tasks
mountPath: /locust-tasks/
livenessProbe:
periodSeconds: 30
httpGet:
path: /
port: {{ .Values.service.internalPort }}
readinessProbe:
periodSeconds: 30
httpGet:
path: /
port: {{ .Values.service.internalPort }}
volumes:
- name: "locust-tasks"
configMap:
name: {{ template "locust.worker-configmap" . }}
restartPolicy: Always
39 changes: 39 additions & 0 deletions common/charts/locust/templates/master-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "locust.master-svc" . }}
labels:
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: {{ template "locust.fullname" . }}
component: "master"
{{- range $key, $value := .Values.service.extraLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.service.annotations }}
annotations:
{{- range $key, $value := .Values.service.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- name: {{ .Values.service.name }}
port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
nodePort: {{ .Values.service.nodePort }}
protocol: TCP
- name: master-p1
port: 5557
protocol: TCP
targetPort: 5557
- name: master-p2
port: 5558
protocol: TCP
targetPort: 5558
selector:
app: {{ template "locust.fullname" . }}
component: "master"
sessionAffinity: None
11 changes: 11 additions & 0 deletions common/charts/locust/templates/worker-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "locust.worker-configmap" . }}
labels:
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: {{ template "locust.fullname" . }}
data:
{{ (.Files.Glob "tasks/*").AsConfig | indent 2 }}
Loading