Skip to content
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

Chore: improve integration tests output and reduce noise #693

Merged
merged 5 commits into from
Aug 17, 2023

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

Solution

@@ -91,7 +94,7 @@ if err != nil {

func ResourceGetFailure(resourceName string, d *schema.ResourceData, err error) diag.Diagnostics {
if frerr, ok := err.(*http.FailedResponseError); ok && frerr.NotFound() {
log.Printf("[WARN] Drift Detected: Terraform will remove %s from state", d.Id())
tflog.Warn(ctx, "Drift Detected: Terraform will remove id from state", map[string]interface{}{"id": d.Id()})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the only change...
the rest vscode plugin formatting the readme file.

_, err := uuid.Parse(id)
if err == nil {
log.Println("[INFO] Resolving credentials by id: ", id)
tflog.Info(ctx, "Resolving credentials by id", map[string]interface{}{"id": id})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Everything is now using tflog.
fmt.Printf has been deprecated.

SetRetryCount(5).
SetRetryWaitTime(time.Second).
SetRetryMaxWaitTime(time.Second * 5).
OnBeforeRequest(func(c *resty.Client, r *resty.Request) error {
tflog.SubsystemInfo(subCtx, "env0_api_client", "Sending request", map[string]interface{}{"method": r.Method, "url": r.URL})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

some more logs.

@@ -155,26 +155,37 @@ func configureProvider(version string, p *schema.Provider) schema.ConfigureConte
isIntegrationTest = true
}

restyClient.
subCtx := tflog.NewSubsystem(ctx, "env0_api_client")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using a subcontext you can filter api_client logs by grep-ing "env0_api_client"

tflog.SubsystemInfo(subCtx, "env0_api_client", "Received respose", map[string]interface{}{"method": r.Request.Method, "url": r.Request.URL, "status": r.Status()})
return nil
}).
AddRetryAfterErrorCondition().
Copy link
Collaborator Author

@TomerHeber TomerHeber Aug 15, 2023

Choose a reason for hiding this comment

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

This may have been needed to retry 4xx and 5xx.
Not sure... but worth checking it out if it helps (documentation isn't very clear).

Copy link
Collaborator Author

@TomerHeber TomerHeber Aug 15, 2023

Choose a reason for hiding this comment

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

looking in the code... it's just:

	c.AddRetryCondition(func(response *Response, err error) bool {
		return response.IsError()
	})
	return c
}

but we'll try...

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Aug 17, 2023
@yaronya yaronya merged commit 4483844 into main Aug 17, 2023
5 checks passed
@yaronya yaronya deleted the chore-improve-integration-output-#691 branch August 17, 2023 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore dependency-change integration-tests provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants