The Simplest Way to Make Cohesity and Pytest Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair cohesity and pytest to test backup rules and restore jobs with code. The test runner calls the data platform API to check snapshot states after each deploy. Manual backup checks take too much time for busy ops teams. Automated test suites catch broken backup policies before a real outage hits your servers. You can run these checks on a set schedule or inside a build pipeline. This workflow turns slow disaster recovery drills into fast daily checks. How cohesity and pytest share dat

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair cohesity and pytest to test backup rules and restore jobs with code. The test runner calls the data platform API to check snapshot states after each deploy.

Manual backup checks take too much time for busy ops teams. Automated test suites catch broken backup policies before a real outage hits your servers. You can run these checks on a set schedule or inside a build pipeline. This workflow turns slow disaster recovery drills into fast daily checks.

How cohesity and pytest share data and logins

Pytest runs your test scripts and sends web requests to the Cohesity cluster. Before a test can check a backup job, it must log in with a valid key. The test setup fixture asks the cluster for a session token or reads a stored API key. Once logged in, the test queries the cluster for job status, snapshot age, and policy rules.

The cluster checks the role attached to that login key. If the role allows read rights, the cluster sends back JSON data about recent backup runs. Pytest then compares that response against your expected values. For example, a test can check that every database snapshot finished within the last six hours.

Some tests also start a test restore to a sandbox target. Those runs need write rights on the test namespace, not just read rights. Keeping read tests separate from write tests makes role setup much safer for your team.

Common risks with shared keys and broad roles

Many teams start by putting one admin API key into their build server. Every test run uses that same shared key to talk to the backup cluster. This habit creates a big risk for your stored data. If that key leaks from a test log, an attacker can delete real backups.

Shared accounts also ruin your audit logs. When fifty test jobs use one service user, you cannot tell which job changed a setting. Unlogged queries make it hard to fix broken runs or prove who touched sensitive data.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, create a tight role just for your test runner. Give the daily check role read rights on job status and nothing else. If a test suite must test restores, bind that role to a sandbox view only. Never let a test script touch production storage domains.

You should also lock down network paths between your test runners and the cluster. Run your test agents on a fixed subnet and block all other traffic to the management port. Rotate the test keys often so old credentials do not sit in build settings for months. Also, watch out for personal data in cluster metadata responses. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results.

Structuring fixtures for fast and safe backup checks

Good test design keeps your backup cluster fast and stable. Do not log in again for every single test function in your suite. Use a session fixture so the test runner logs in once per run and reuses the session. This cuts down login noise in your cluster audit logs.

Group your tests by the level of access they need. Run fast, read-only policy checks on every code merge. Schedule heavy restore tests to run once a night in an isolated lab. Clean up any temporary clone objects at the end of the test fixture. If a test fails mid-run, the teardown step must still remove test clones so storage stays clean.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

What permissions should a Pytest runner have in Cohesity?

Give the test runner a read-only role for daily status checks. If you test restores, scope write permissions to a separate sandbox view only.

How do we stop API keys from leaking in test logs?

Turn off verbose header dumps in your test settings and mask secret variables in your build tool. Never print raw login responses when a test fails.

How often should automated backup tests run?

Run read-only policy and SLA checks every few hours or after stack changes. Run full clone and restore tests once a day during low traffic hours.

The query runs. The emails stay hidden.