Skip to main content

Keptn

What you'll learn
  • How to install Artillery integration in Keptn
  • How to trigger different kinds of tests with Keptn's test strategies
  • How to run Artillery smoke tests and load tests in Keptn delivery pipelines
  • How Keptn's SLO evaluation gates work with Artillery's performance metrics

Overview

Keptn is a cloud-native application lifecycle orchestration platform which automates observability, SLO-driven delivery, and operational remediation. Integrating Artillery in your Keptn delivery pipelines allows you to run pre and post-deployment load and smoke tests with Artillery to verify that new releases of a service work as expected and meet their performance SLOs.

Setting up Keptn Artillery Service

Artillery's official integration with Keptn is available on https://github.com/keptn-sandbox/artillery-service. To install the integration, clone the repository, and use kubectl to install the integration:

kubectl apply -f deploy/service.yaml

This will install the artillery-service service, along with a Keptn distributor into the keptn namespace on the Kubernetes cluster.

For information on upgrading or downgrading an existing installation, or uninstalling the integration, please refer to the README guide.

Running Artillery tests

The following Artillery code is a basic test for sock shop, a sample ecommerce service maintained by the Keptn project.

info

The URL of the current deployment may change between deployments. Current URL is injected into the Artillery environment automatically by the integration.

config:
# Use the expectations plugin to run checks and assertions
# More information:
# https://artillery.io/docs/guides/plugins/plugin-expectations-assertions
plugins:
expect: {}
scenarios:
- flow:
#
# Check that root path returns a 200:
#
- get:
url: "/"
expect:
- statusCode: 200
#
# Add an item to cart. We expect a 201 response to indicate success:
#
- post:
url: "/carts/1/item"
json:
itemId: 03fef6ac-1896-4ce8-bd69-b798f85c6e0f
unitPrice: 99
expect:
- statusCode: 201

Default Artillery test script

The integration will look for an Artillery test script in scenarios/load.yaml by default. The file may be added to Keptn with the following command:

keptn add-resource --project=PROJECTNAME --service=SERVICENAME --stage=STAGENAME --resource=./scenarios/load.yaml --resourceUri=scenarios/load.yaml

Configuring test strategies

More advanced test strategies can be configured with a artillery.conf.yaml file that can specify which Artillery tests should run for different stages of your Keptn pipeline.

The following example sets three different test strategies:

  1. functional, for an end-to-end functional test of the service
  2. performance, to run a load test
  3. and smoke for a smoke test (a health check)
---
spec_version: '0.1.0'
workloads:
- teststrategy: functional
script: scenarios/basic.yaml
- teststrategy: performance
script: scenarios/load.yaml
- teststrategy: smoke
script: scenarios/health.yaml

The configuration file can be applied with:

keptn add-resource --project=PROJECTNAME --service=SERVICENAME --all-stages --resource=artillery.conf.yaml --resourceUri=scenarios/artillery.conf.yaml

Quality gates and SLO checks

Keptn quality gates provide a way to define quality criteria of your service in a declarative way. All existing quality gates and SLO definitions work with this integration with no extra work required.

Learn more