# Check infrastructure health with CIT

> Build a CIT test that verifies a resource handler's connection, so you find a broken cloud before your users do

---

Site [llms.txt](/llms.txt)

---

A resource handler is the starting point for provisioning a server and for running remote scripts through a platform's own channel, so its connection is worth checking on a schedule rather than when an order fails. This example uses Cloud Management Platform (CMP) Continuous Infrastructure Testing to do that. For CIT itself, see [Continuous Infrastructure Testing (CIT)](/docs/cmp/use/orchestration/cit/).

## Prerequisites

- You are a super admin in CMP.
- A [resource handler](/docs/cmp/configure/infrastructure/resource-handlers/) is already configured.
- You have its [resource handler ID](/docs/cmp/configure/infrastructure/resource-handlers/).

## Create the test

1. Go to **Admin** > **Continuous Infrastructure Testing**.
1. Select **Add** > **New Action Test**.
1. Select **CloudBolt Plug-in** > **+ Add a New CloudBolt Plug-in**.
1. Enter a name, then scroll to the bottom of the form.
1. For **File Location**, select **Enter code later**.
1. Select **Create**.

## Add the code

1. Find the new test in the **Tests** list and select its name.
1. Under **Actions**, select the action name to open the plugin for editing.
1. Replace the default code with the following, then save.

```python
from common.methods import set_progress
from resourcehandlers.models import ResourceHandler
from utilities.logger import ThreadLogger

logger = ThreadLogger(__name__)


def run(*args, **kwargs):
    rh = ResourceHandler.objects.get(id=int("{{ resource_handler }}"))
    rh = rh.cast()
    if rh.can_verify_connection:
        set_progress(f"Verifying connection to '{rh}'.")
        rh.verify_connection()
        set_progress(f"Successfully verified connection to '{rh}'.")
```

The plugin reads a resource handler ID from an action input, casts the handler to its concrete type, and calls `verify_connection()` on it if that handler supports connection checks.

## Supply the resource handler ID

1. Return to the Continuous Infrastructure Testing page.
1. Under **Tests**, select the pencil icon in the **Action** column.
1. Enter the [resource handler ID](/docs/cmp/configure/infrastructure/resource-handlers/) in **Default value for Resource Handler**.
1. Select **Save Changes**.

## Run it

1. On the Continuous Infrastructure Testing page, select **Execute Tests** > **Execute All Tests**.
1. Select the test name to see its details and status.

A job is created, and it passes or fails according to the health of the resource handler's connection. To have this run on a schedule, see [Schedule tests](/docs/cmp/use/orchestration/cit/#schedule-tests).

## Related

- [Continuous Infrastructure Testing (CIT)](/docs/cmp/use/orchestration/cit/): creating, scheduling, and reading tests generally.
- [Resource handlers](/docs/cmp/configure/infrastructure/resource-handlers/): configuring the connection being tested.
