Skip to content

Recreate deleted k6 resources #2173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 23, 2025
Merged

Recreate deleted k6 resources #2173

merged 18 commits into from
May 23, 2025

Conversation

fornfrey
Copy link
Contributor

@fornfrey fornfrey commented May 14, 2025

  • Ensure that k6 resources (Projects, Load Tests) create a Terraform drift instead of raising an error when deleted outside of Terraform.
  • Add tests to verify the resources are removed from the state when not found on the backend.
  • Update existing tests to generate unique k6 project names.

@fornfrey fornfrey requested a review from joanlopez May 14, 2025 15:38
@fornfrey fornfrey requested a review from a team as a code owner May 14, 2025 15:38
@CLAassistant
Copy link

CLAassistant commented May 14, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@fornfrey fornfrey force-pushed the k6-resource-read-fix branch from 2338b21 to 371f96c Compare May 14, 2025 15:51
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @fornfrey!

I think it could be a very nice idea to try to write a test that:

  • Loads a config directory, with a given resource (and so it creates it)
  • Use the Go client/direct HTTP request to remove it.
  • Try to reload the configuration, and see how it behaves (no error).

However, I'm not sure how easy that would be, and if there's any similar test for any other resource within the provider. If so, and it's easy to copy and adjust, I'd try it, if not, feel free to merge it as-is! We could look at it later.

Thanks! 🙌🏻

@fornfrey fornfrey requested a review from a team as a code owner May 19, 2025 15:20
@fornfrey fornfrey requested review from facundobatista and federicotdn and removed request for a team May 19, 2025 15:20
@fornfrey fornfrey requested a review from joanlopez May 20, 2025 13:54
script, httpResp, err := scriptReq.Execute()

if httpResp != nil && httpResp.StatusCode == http.StatusNotFound {
// 404 response from the script endpoin for an existing test means that the script is undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 404 response from the script endpoin for an existing test means that the script is undefined
// 404 response from the script endpoint for an existing test means that the script is undefined

Copy link
Member

@spinillos spinillos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fix the cloud tests 😃

@fornfrey fornfrey merged commit f2fd705 into main May 23, 2025
30 checks passed
@fornfrey fornfrey deleted the k6-resource-read-fix branch May 23, 2025 11:15
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.

5 participants