Responsive

Streamline K8s Testing with Testkube’s Slack Notifications

Mar 30, 2023
4 min
read
Alejandra Thomas
Developer Advocate
Testkube
Monitoring the state & results of our tests can become a headache as we scale and deploy our applications into Kubernetes. Stay updated with the state of your tests by configuring Slack and Testkube.
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on HackerNews
Copy URL

Table of Contents

Want to learn more about this topic? Check out our Office Hours session...

Start Using Testkube with a Free Trial Today

Subscribe to our monthly newsletter to stay up to date with all-things Testkube.

Monitoring the state and results of our tests can become a real headache as we scale and deploy our applications into Kubernetes. While it’s important to keep a close eye on our tests, this can get complicated when we’re testing at high speed and volumes.

At Testkube, we know the importance of asynchronous monitoring and testing, which is why we support different ways to stay on top of what’s happening: triggering tests based on different events with Test Triggers, letting you visualize your executions over time through our Testkube Dashboard, and setting up Slack notifications as one way to keep track of the state of your applications.

New here? Testkube is a Kubernetes-native testing framework for testers, developers, and DevOps practitioners. It acts as an executor so you can orchestrate, run, and display tests and test results for your code in a Kubernetes environment. Whether you're new to the K8s ecosystem or a seasoned pro, Testkube lets you focus on testing without having to complicate yourself, your processes, or your pipelines.

In this short tutorial, I’ll show you how to set up Slack notifications for your tests running in Kubernetes so you find out right away when a test is started, if it passed or failed, or whether it was aborted or timed out.

Prerequisites

Install Testkube

To get started, you’ll need to have an instance of Testkube installed and initiated in your Kubernetes cluster. Head over to our Installation Guide to kick-off your testing journey. 

If you’d like to install Testkube manually, download Testkube’s binary (available here), unpack it, and move it to the PATH. You will need to separately install kubectl and helm as well. To manually use Helm to install Testkube’s components, please refer to our documentation.

Now that we have Testkube up and running, let’s set up our Slack notifications!

Install the Testkube bot on Slack

You’ll need to install Testkube bot onto your Slack workspace. To do this, follow this link. You’ll be able to see what permissions you’ll need to provide and accept in the following screen:

Once you allow for the installation, you’ll immediately get an authorization confirmation and your unique `slackToken`. Make sure you keep this saved since we’ll need it for our next step:

Edit values file with slackToken

Now that we’ve added the Testkube bot to our Slack workspace and have our slackToken in hand, it’s time to add it to our Testkube configuration. We will need to edit our values in our Testkube helm chart, to do this, you can type the following command from your terminal and edit the `slackToken` value in place:

```bash

kubectl edit deployment testkube-api-server -n testkube

```

Enter your slackToken here and save!

Add Testkube bot to channel

To start receiving notifications for your tests, you’ll need to add the bot to a channel within your workspace or edit your `slack-config.json` file:

```json

[

    {

      "ChannelID": "",

      "selector": {},

      "testName": [],

      "testSuiteName": [],

      "events": [

        "start-test",

        "end-test-success",

        "end-test-failed",

        "end-test-aborted",

        "end-test-timeout",

        "start-testsuite",

        "end-testsuite-success",

        "end-testsuite-failed",

        "end-testsuite-aborted",

        "end-testsuite-timeout"

      ]

    }

  ]

```

By modifying this file, you can select which events you’d like to be notified about - by leaving it as is, you’ll receive notifications for all events: 

  • When a test or test suite is started
  • Whether a test or test suite succeeds or fails
  • Tests ending because of abortions
  • Test ending because of timeouts

If you simply want to receive all notifications in a specific channel, you can manually add the Testkube bot to it and not modify the JSON file.

Note that we currently only support notifications on public channels.

Create and run your tests

We’ve successfully configured our Testkube Slack bot! Now, whenever you perform an event through Testkube, you’ll receive notifications to the channel you added the bot to:

By default, you’ll get information on your tests or test suites such as Name, Type, Start and End Times, Duration, and any error messages or steps failed on execution.

You can modify or configure this template according to your needs by customizing the `slack-template.json` file. For more information about this, you can check out our documentation.

And that’s it. By following these simple steps, you can streamline your process and configure Testkube and Slack to get notified on the status of your applications in Kubernetes! 

Still got questions? Check out our documentation for a more detailed overview on how to set up and customize your Slack messages.

Give it a go!

Why not give it a go yourself? Sign up to Testkube and try one of our examples or head over to our documentation - if you get stuck or have questions, we’re here to help! Find an answer to your questions in the Testkube Knowledge Base or reach out to us on Slack. We’re eager to hear how you use our integrations!

Alejandra Thomas
Developer Advocate
Testkube
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on HackerNews
Copy URL