Skip to main content

Integration Tests for py-marqo

This document explains how to run the integration tests in the py-marqo project. You can run tests against either:

  • Open Source Marqo
  • Marqo Cloud

๐Ÿ”ง Running Tests Against Open Source Marqoโ€‹

To run integration tests against a local Open Source Marqo instance, simply use:

tox

This assumes Marqo is running locally (typically on http://localhost:8882).

๐Ÿงน Index and Document Cleanupโ€‹

Open Source tests enforce strict isolation by:

Note: The delete-all API is disabled in Marqo Cloud for security reasons. This causes behavioral differences between Open Source and Cloud test runs.


โ˜๏ธ Running Tests Against Marqo Cloudโ€‹

To run integration tests against Marqo Cloud, set the following environment variables:

Required Environment Variablesโ€‹

export MARQO_CLOUD_URL=https://your-cloud-instance.marqo.ai # Should match MARQO_URL for non-default cloud environments (e.g. staging)
export MARQO_API_KEY=your_api_key_here # Your Marqo Cloud API key
export MARQO_URL=https://your-cloud-instance.marqo.ai # Marqo Cloud endpoint
  • MARQO_CLOUD_URL is used internally to determine if the test suite is targeting Marqo Cloud. It should be equal to MARQO_URL for non-default environments such as staging.

Running the Testsโ€‹

tox -e cloud_tests

โš™๏ธ Optional Arguments for Cloud Testsโ€‹

The cloud test suite supports several additional arguments:

ArgumentDefaultDescription
create-indexesFalseIf True, creates test indexes before test execution. Skips any that already exist.
delete-indexesFalseIf True, deletes indexes after tests complete.
use-unique-identifierFalseIf True, appends a unique suffix to index names to avoid collisions.

Exampleโ€‹

tox -e cloud_tests -- create-indexes=True use-unique-identifier=False delete-indexes=True

๐Ÿงน Document Cleanup Behavior (Cloud vs Open Source)โ€‹

AspectOpen SourceCloud
Document CleanupUses documents/delete-all API between every testTracks document IDs and performs individual deletions in tearDown
Index CleanupDeletes indexes between test classesOptional: controlled via delete-indexes argument
Isolation LevelHigh (reset state between tests)Moderate (controlled via parameters)

โš ๏ธ Important: These differences can lead to test suite discrepancies between Open Source and Cloud runs, especially in tests relying on full state resets.


๐Ÿ†” Custom Index Identifierโ€‹

If use-unique-identifier=True, a random suffix is generated to avoid collisions between test runs.

To define a custom identifier:

export MQ_TEST_RUN_IDENTIFIER=my-custom-id

This is useful for debugging or tracking test runs in shared environments.


โœ… Running Tests via GitHub Actionsโ€‹

You can trigger integration tests on a branch using the Cloud Integration Tests GitHub Action.

Default Behaviorโ€‹

  • Tests will run in the default Marqo Cloud test account.
  • Indexes will be deleted automatically after the run finishes.

โš ๏ธ Do not cancel the action after it has started, as this may leave indexes behind.

Cleaning Up Leftover Indexesโ€‹

To manually clean up leftover indexes from the Cloud test account:

  1. Trigger the same Cloud Integration Tests action.
  2. Set the input job_to_run to delete_all_indexes.

This will remove all test-created indexes safely.


๐Ÿ“Œ Summaryโ€‹

  • Use tox for Open Source, and tox -e cloud_tests for Cloud.
  • Set all required environment variables when targeting Cloud.
  • Be aware of differences in document and index cleanup logic that may affect test results.
  • Use GitHub Actions for automated CI tests and cleanup tasks.

Happy testing! ๐Ÿš€