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

TestAPIGitTags Fails To Read Correct User On Drone Docker Runner #14247

Closed
2 of 6 tasks
kdumontnu opened this issue Jan 5, 2021 · 7 comments · Fixed by #19512
Closed
2 of 6 tasks

TestAPIGitTags Fails To Read Correct User On Drone Docker Runner #14247

kdumontnu opened this issue Jan 5, 2021 · 7 comments · Fixed by #19512

Comments

@kdumontnu
Copy link
Contributor

  • Gitea version (or commit ref):
  • Git version (SHA): cfc3916
  • Operating system: docker image: golang:1.15
platform:
  os: linux
  arch: amd64

services:
  - name: pgsql
    pull: default
    image: postgres:12
    environment:
      POSTGRES_DB: test
      POSTGRES_PASSWORD: postgres

steps:
  - name: test-pgsql
    image: golang:1.15
    commands:
      - "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash"
      - apt-get install -y git-lfs
      - timeout -s ABRT 40m make test-pgsql-migration test-pgsql
    environment:
      GOPROXY: off
      TAGS: bindata
      TEST_LDAP: 1
      USE_REPO_TEST_DIR: 1
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:
=== TestAPIGitTags (integrations/api_repo_git_tags_test.go:20)
--
166 | --- FAIL: TestAPIGitTags (0.55s)
167 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:95:1() [I] Completed GET /api/v1/repos/user2/repo1/git/refs/heads/unknown?token=9b325eff34509b0c785ab027003729a350cdb815 0  in 31.289586ms
168 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:88:1() [I] Started GET /user/settings/applications for
169 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:95:1() [I] Completed GET /user/settings/applications 0  in 7.005154ms
170 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:88:1() [I] Started POST /user/settings/applications for
171 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:95:1() [I] Completed POST /user/settings/applications 0  in 22.903611ms
172 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:88:1() [I] Started GET /user/settings/applications for
173 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:95:1() [I] Completed GET /user/settings/applications 0  in 6.910047ms
174 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:88:1() [I] Started GET /api/v1/repos/user2/repo1/git/tags/692695075cdd379eebde360da52777fab043ee18?token=4ba9396fdf49c98b36c9807148b9fa4edfe54954 for
175 | api_repo_git_tags_test.go:54:
176 | Error Trace:	api_repo_git_tags_test.go:54
177 | Error:      	Not equal:
178 | expected: "user2"
179 | actual  : "Kyle D"
180 |  
181 | Diff:
182 | --- Expected
183 | +++ Actual
184 | @@ -1 +1 @@
185 | -user2
186 | +Kyle D
187 | Test:       	TestAPIGitTags
188 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:95:1() [I] Completed GET /api/v1/repos/user2/repo1/git/tags/692695075cdd379eebde360da52777fab043ee18?token=4ba9396fdf49c98b36c9807148b9fa4edfe54954 0  in 51.374277ms
189 | api_repo_git_tags_test.go:55:
190 | Error Trace:	api_repo_git_tags_test.go:55
191 | Error:      	Not equal:
192 | expected: "[email protected]"
193 | actual  : "[email protected]"
194 |  
195 | Diff:
196 | --- Expected
197 | +++ Actual
198 | @@ -1 +1 @@
199 | [email protected]
200 | [email protected]
201 | Test:       	TestAPIGitTags
202 | testlogger.go:78: 2021/01/04 16:51:57 ...outers/routes/chi.go:88:1() [I]

Description

CI runner is failing on TestAPIGitTags using the settings above. It appears that the git user and git email are not read correctly from the annotated tag. It resolves to my user credentials instead of the mock credentials from the test. It actually appears that the API is working fine, because gitRepo.GetTag(aTagName) returns the same info that the API request is getting. In fact, I've updated the test to:

	assert.Equal(t, aTag.Tagger.Name, tag.Tagger.Name)
	assert.Equal(t, aTag.Tagger.Email, tag.Tagger.Email)

However, there still appears to be an issue with either writing via CreateAnnotatedTag or reading via GetTag because, as I understand it, neither case should use my system credentials.

@kdumontnu
Copy link
Contributor Author

Update

It turns out that the GIT_AUTHOR_NAME and GIT_COMMITTER_NAME env variables are set in my runner and these are overriding the git config settings (which the test sets to user2).

Still, I'd propose that this issue shouldn't be caught by TestAPIGitTags as it's not an problem with API functionality and made it more confusing to debug.

I'd propose the above change should be made to the assertions in TestAPIGitTags and a separate test should be added to TestRepository_GetTag to verify author and email.

@techknowlogick techknowlogick changed the title TestAPIGitTags Fails To Read Correct User On Linux amd64 Runner TestAPIGitTags Fails To Read Correct User On Drone Docker Runner Jan 5, 2021
@techknowlogick
Copy link
Member

Thanks for reporting this :)

For maintainers looking at this, the reason we don't face this is because we are still using the (now deprecated) drone-agent for our builds, and the drone docker runner has a slight change in behaviour.

@kdumontnu
Copy link
Contributor Author

For maintainers looking at this, the reason we don't face this is because we are still using the (now deprecated) drone-agent for our builds, and the drone docker runner has a slight change in behaviour.

Yeah, this issue has exposed a few problems with my drone setup which I'm trying to resolve (mainly: why is drone using my user credentials for git?)

@wxiaoguang
Copy link
Contributor

Outdated

@techknowlogick
Copy link
Member

Re-openening as we have yet to switch to new drone-runner

@lunny
Copy link
Member

lunny commented Apr 26, 2022

I think we can add a skip for that test and enable a new agent and then find a way to fix the test.

techknowlogick added a commit to techknowlogick/gitea that referenced this issue Apr 26, 2022
@zeripath
Copy link
Contributor

I think I've figured out how to fix that test ... #19509 (comment)

zeripath added a commit to zeripath/gitea that referenced this issue Apr 26, 2022
TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix go-gitea#14247

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick pushed a commit that referenced this issue Apr 26, 2022
…19512)

TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix #14247

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick pushed a commit to techknowlogick/gitea that referenced this issue Apr 26, 2022
…o-gitea#19512)

TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix go-gitea#14247

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick added a commit that referenced this issue Apr 26, 2022
…19512) (#19519)

TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix #14247

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: zeripath <[email protected]>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 24, 2022
…o-gitea#19512)

TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix go-gitea#14247

Signed-off-by: Andrew Thornton <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants