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] Failure on 1st test run should not cause 2nd run to fail #35168

Conversation

pjanotti
Copy link
Contributor

@pjanotti pjanotti commented Sep 13, 2024

Description:
If the first run of the tests fails without running the deferred code, the second run will fail on the registry entry already being present so no second run. This change ensures that if the event log source "leaked" from the first run the second run doesn't fail because the source is already present. Related conversation at #35032 (comment)

Testing:
Local runs.

Documentation:
N/A

@@ -301,6 +302,10 @@ func createTestConfig() *WindowsLogConfig {
// It returns a function that can be used to uninstall the event source, that function is never nil
func assertEventSourceInstallation(t *testing.T, src string) (uninstallEventSource func(), err error) {
err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error)
if err != nil && strings.HasSuffix(err.Error(), " registry key already exists") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking for the string because eventlog.InstallAsEventCreate doesn't return the win32 API error, but, a generic error with an english string, see https://cs.opensource.google/go/x/sys/+/refs/tags/v0.25.0:windows/svc/eventlog/install.go;l=44

@dmitryax dmitryax added the Run Windows Enable running windows test on a PR label Sep 13, 2024
@djaglowski djaglowski merged commit db787dd into open-telemetry:main Sep 13, 2024
179 of 180 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 13, 2024
@pjanotti pjanotti deleted the win-eventlog-tests-do-not-fail-if-regkey-exists branch September 13, 2024 15:04
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
receiver/windowseventlog Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants