-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: gitlab client failing test #3653
Conversation
I think the github workflows need to be revisited, |
defaultMR = 1 | ||
noHeadPipelineMR = 2 | ||
defaultMr := 1 | ||
noHeadPipelineMR := 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marceloboeira apparently that wasn't enough, tests are still failing:
=== RUN TestGitlabClient_PullIsMergeable/atlantis-test/plan#02
gitlab_client_test.go:423: got unexpected request at "/api/v4/projects/4580910/repository/commits/sha/statuses"
gitlab_client_test.go:451: unexpected error: GET http://127.0.0.1:52736/api/v4/projects/4580910/repository/commits/sha/statuses: 404 failed to parse unknown error format: not found
--- FAIL: TestGitlabClient_PullIsMergeable/atlantis-test/plan#02 (1.09s)
Is a case missing in
atlantis/server/events/vcs/gitlab_client_test.go
Lines 397 to 425 in 4b34055
switch r.RequestURI { | |
case "/api/v4/": | |
// Rate limiter requests. | |
w.WriteHeader(http.StatusOK) | |
case "/api/v4/projects/runatlantis%2Fatlantis/merge_requests/1": | |
w.WriteHeader(http.StatusOK) | |
w.Write([]byte(pipelineSuccess)) // nolint: errcheck | |
case "/api/v4/projects/runatlantis%2Fatlantis/merge_requests/2": | |
w.WriteHeader(http.StatusOK) | |
w.Write([]byte(headPipelineNotAvailable)) // nolint: errcheck | |
case "/api/v4/projects/4580910": | |
w.WriteHeader(http.StatusOK) | |
w.Write([]byte(projectSuccess)) // nolint: errcheck | |
case "/api/v4/projects/4580910/repository/commits/67cb91d3f6198189f433c045154a885784ba6977/statuses": | |
w.WriteHeader(http.StatusOK) | |
response := fmt.Sprintf(`[{"id":133702594,"sha":"67cb91d3f6198189f433c045154a885784ba6977","ref":"patch-1","status":"%s","name":"%s","target_url":null,"description":"ApplySuccess","created_at":"2018-12-12T18:31:57.957Z","started_at":null,"finished_at":"2018-12-12T18:31:58.480Z","allow_failure":false,"coverage":null,"author":{"id":1755902,"username":"lkysow","name":"LukeKysow","state":"active","avatar_url":"https://secure.gravatar.com/avatar/25fd57e71590fe28736624ff24d41c5f?s=80&d=identicon","web_url":"https://gitlab.com/lkysow"}}]`, c.status, c.statusName) | |
w.Write([]byte(response)) // nolint: errcheck | |
case "/api/v4/version": | |
w.WriteHeader(http.StatusOK) | |
w.Header().Set("Content-Type", "application/json") | |
type version struct { | |
Version string | |
} | |
v := version{Version: serverVersion} | |
json.NewEncoder(w).Encode(v) | |
default: | |
t.Errorf("got unexpected request at %q", r.RequestURI) | |
http.Error(w, "not found", http.StatusNotFound) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh 😮💨
thanks for bringing this up.
I'm curious how the tests passed din the MR build... let me take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were skipped 😕 #3653 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try changing like 448 from "sha" to "67cb91d3f6198189f433c045154a885784ba6977"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's what's causing the problem since the mock is expecting a commit hash instead of "sha" in the URL. Alternatively we could create a mock for "sha" for isolation but I don't see an additional value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marceloboeira that solves most of the failures, but still some test cases fail with:
gitlab_client_test.go:452: [true != false]
This test case:
atlantis/server/events/vcs/gitlab_client_test.go
Lines 384 to 390 in 63dcd43
{ | |
fmt.Sprintf("%s/plan", vcsStatusName), | |
models.SuccessCommitStatus, | |
gitlabServerVersions, | |
noHeadPipelineMR, | |
true, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we have to revert the MR so we fix the build, I won't have time to look into it, it might be the default to isPipelineSkipped := true
is the problem but I will have to open another MR with the fix (and figure out if we can have the CI running the tests or get them working properly locally)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marceloboeira that is indeed the case. I don't have much experience with Gitlab API so I can't tell what should be the correct behavior here.
Unless you think that the broken test might mean an incorrect behavior, how about removing this test case for now and then later you could look into it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code definitely fixes the nil pointer (which caused panic) but by fixing it it might have exposed a logic issue. In any case, it is very niche. If you want to remove/comment the test I will open another MR soon to fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, if you manage to merge your pull request first, I will close this one.
@GenPage @jamengual could you take a look at this pull request to resolve failing |
Looks good, thanks @ghaiszaher! |
This reverts commit 25c6b43.
By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: runatlantis#3428 * Tests Patch MR : runatlantis#3653
By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: runatlantis#3428 * Tests Patch MR : runatlantis#3653
By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: runatlantis#3428 * Tests Patch MR : runatlantis#3653
#3695) By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: #3428 * Tests Patch MR : #3653
* fix: gitlab client failing test * change HeadCommit to `67cb91d3f6198189f433c045154a885784ba6977` * remove test case for now
runatlantis#3695) By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: runatlantis#3428 * Tests Patch MR : runatlantis#3653
* fix: gitlab client failing test * change HeadCommit to `67cb91d3f6198189f433c045154a885784ba6977` * remove test case for now
runatlantis#3695) By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further: When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless) The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test. In order to prevent further problems, this MR: * Updates the test stack to run all plan/apply commands in the context of "HeadLess" Pipelines * Fixes the default of skipped pipeline to false (as it is better to assume it is NOT skipped since that prevents the merge in most cases) * Make all integratiion tests pass References: * Original MR: runatlantis#3428 * Tests Patch MR : runatlantis#3653
what