Skip to content

Conversation

@aayushsingh2502
Copy link
Collaborator

Following functions are created:
1. list(workspace_id, options) - Lists all query runs for a workspace with automatic pagination
2. create(options) - Creates a new query run with workspace and optional configuration version
3. read(query_run_id) - Retrieves query run details by ID
4. read_with_options(query_run_id, options) - Reads query run with relationship includes (created_by, configuration_version)
5. logs(query_run_id) - Retrieves query run execution logs as an IO stream
6. cancel(query_run_id, options) - Gracefully cancels a running query run with optional comment
7. force_cancel(query_run_id, options) - Force cancels a stuck query run with optional comment

Note: The functions were pointing to wrong endpoints. That is also fixed as part of this PR

Output from Manual testing

================================================================================
QUERY RUN FUNCTION TESTS
================================================================================
Testing all Query Run API operations

NOTE: Query Runs require Terraform 1.10+ with 'terraform query' command.
      Most query runs will error since this feature is not yet available.
================================================================================
=== Test 1: List Query Runs ===
Found 34 query runs in workspace 'query-test'
  1. qry-ibSqakxbRdakQMjs
     Status: QueryRunStatus.ERRORED
     Created: 2025-12-21 14:00:31.981000+00:00

  2. qry-ZhaCWyppLrya3rmr
     Status: QueryRunStatus.CANCELED
     Created: 2025-12-21 14:00:24.924000+00:00

  3. qry-xYywfhd3Vjr17nWi
     Status: QueryRunStatus.ERRORED
     Created: 2025-12-21 14:00:16.967000+00:00

  4. qry-ZdGNVnx26D83FSTM
     Status: QueryRunStatus.ERRORED
     Created: 2025-12-21 13:33:36.802000+00:00

  5. qry-kk6VXT1FXzSWYPRv
     Status: QueryRunStatus.CANCELED
     Created: 2025-12-21 13:33:30.209000+00:00

Retrieved 34 query runs (page_size=5)

=== Test 2: Create Query Run ===
Using configuration version: cv-6rVj5eRunDdUMmU7
Created query run: qry-tk8NwVHzU2xZ4GDp
  Status: QueryRunStatus.QUEUED
  Source: tfe-api
  Created: 2025-12-21 14:03:40.545000+00:00

=== Test 3: Read Query Run ===
Read query run: qry-ibSqakxbRdakQMjs
  Status: QueryRunStatus.ERRORED
  Source: tfe-api
  Created: 2025-12-21 14:00:31.981000+00:00
  Status Timestamps:
    Queued: 2025-12-21 14:00:31.996000+00:00
    Running: 2025-12-21 14:00:33.637000+00:00
    Errored: 2025-12-21 14:00:36.708000+00:00

=== Test 4: Get Query Run Logs ===
Error: HTTP 400
  Note: Logs may not be available if the query run hasn't started yet

=== Test 5: Cancel Query Run ===
Creating a new query run to cancel...

=== Test 2: Create Query Run ===
Using configuration version: cv-6rVj5eRunDdUMmU7
Created query run: qry-TKaKUPfMQuTDrFzb
  Status: QueryRunStatus.QUEUED
  Source: tfe-api
  Created: 2025-12-21 14:03:49.719000+00:00
Cancel requested for query run: qry-TKaKUPfMQuTDrFzb
  Status after cancel: QueryRunStatus.CANCELED

=== Test 6: Force Cancel Query Run ===
Creating a new query run to force cancel...

=== Test 2: Create Query Run ===
Using configuration version: cv-6rVj5eRunDdUMmU7
Created query run: qry-e2XdPXaJW6QfhRsm
  Status: QueryRunStatus.QUEUED
  Source: tfe-api
  Created: 2025-12-21 14:03:57.003000+00:00
Error: Not found. This resource does not exist or may need to be authenticated
  Note: Query run may not be in a force-cancelable state

TestCase Run:

Screenshot 2025-12-21 at 7 38 55 PM

@aayushsingh2502 aayushsingh2502 requested a review from a team as a code owner December 21, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant