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

Do not hard-code PostgreSQL credentials in tester file #2339

Closed
wants to merge 1 commit into from

Conversation

strk
Copy link
Member

@strk strk commented Aug 19, 2017

This allows running tests against non-default installs

NOTE: I suppose the change in .drone.yml will require signing it
again, which I cannot do. Can you help @lunny $bkcsoft $appleboy ?

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

I think Makefile also needs changes so that running make test-pgsql etc would also have defaults

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 19, 2017
@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

and then you would probably not need .drone.yml changes

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

Adding these lines somewhere in the beginning of Makefile:

PGUSER ?= postgres
PGPASSWORD ?= postgres
PGHOST ?= 127.0.0.1
PGPORT ?= 5432

and using your pgsql.ini file allows me to run PGUSER=testgitea make test-pgsql successfully

@lafriks lafriks added type/enhancement An improvement of existing functionality type/testing labels Aug 19, 2017
@lafriks lafriks added this to the 1.x.x milestone Aug 19, 2017
Copy link
Member

@lafriks lafriks left a comment

Choose a reason for hiding this comment

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

Do not change .drone.yml file but make changes only to Makefile as I suggested in comments

@strk
Copy link
Member Author

strk commented Aug 19, 2017

the reason I had to make these changes was to be able to run make test-pgsql on my system, and I was able due to my libpq defaults and/or libpq supported env variables. If I hard-code those values in the Makefile the purpose of this change would be defeated. My point is that it should be configurable how to connect, and it is already, via libpq supported env variables. Let's not override those with hard-coded values.

Note I already changed .drone.yml in this PR. And I'm happy to see there was no need to update the signature file (drone/pr build succeeds)

@strk
Copy link
Member Author

strk commented Aug 19, 2017

I dunno why those many changes were added to the .ini file though, I only removed 3 lines, must be something related to .editorconfig, should I revert-clean ?

@strk strk force-pushed the no-force-pgsql-credentials branch from ee413ee to 3b1bbed Compare August 19, 2017 22:31
@strk
Copy link
Member Author

strk commented Aug 19, 2017

force-pushed after cleaning up the changes in .ini file

@daviian
Copy link
Member

daviian commented Aug 19, 2017

The changes are created by make test-pgsql

@strk
Copy link
Member Author

strk commented Aug 19, 2017

oh, that's an issue that should also be fixed (maybe in a different PR).
Source files should not be changed by test targets, IMHO

@daviian
Copy link
Member

daviian commented Aug 19, 2017

I automatically do a git reset integrations/pgsql.ini so it wasn't a problem for me til now ;-)

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

@strk if you have these variables set makefile wont change them but just reuse yours. ?= sets just defaults if you don't have environment variables so it will work for everyone.

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

Looks like you also need to change:

test-pgsql: integrations.test
	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test

to:

test-pgsql: integrations.test
	PGHOST=${PGHOST} PGPORT=${PGPORT} PGUSER=${PGUSER} PGPASSWORD=${PGPASSWORD} GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test

@strk
Copy link
Member Author

strk commented Aug 20, 2017 via email

@lafriks
Copy link
Member

lafriks commented Aug 20, 2017

ok, you convinced me through I will still need to set env variables to run tests 👍

@lafriks
Copy link
Member

lafriks commented Aug 20, 2017

@go-gitea/owners does .drone.yml needs to be signed again?

@lafriks
Copy link
Member

lafriks commented Aug 20, 2017

otherwise LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 20, 2017
@strk
Copy link
Member Author

strk commented Aug 20, 2017

@daviian for the record #2346 fixes the override of source file (if you want to test)

@lafriks
Copy link
Member

lafriks commented Sep 13, 2017

As #2484 is merged are these changes still needed?

@strk
Copy link
Member Author

strk commented Sep 26, 2017

Well I like it more to be able to use my already-existing environment rather than (as done by #2484) enforce the use of custom env variables...

I've rebased to master and fixed conflicts.

@strk
Copy link
Member Author

strk commented Sep 26, 2017

The thing is that enforcing a setting for PG host/user/port prevents using libpq defaults. I like the idea of using what already exists (defaults)

@strk
Copy link
Member Author

strk commented Sep 26, 2017

The integration test actually still fails for me :(

Unsupported RDBMS for integration tests
Makefile:181: recipe for target 'test-pgsql' failed

Ideas ?

@lafriks
Copy link
Member

lafriks commented Sep 26, 2017

pghost must be pgsql not 127.0.0.1 in drone

@lafriks
Copy link
Member

lafriks commented Sep 30, 2017

I don't think it's correct to use user defaults for integration tests as at least for me PG defaults are used for PostgreSQL admin user (username&host) so I don't have to use that for psql command. I would not like to use them for integration tests. Current approach is more configurable for everyone as you can set specific environment variables just for gitea and easily run just make test-pgsql

This allows running tests against non-default installs
@strk strk force-pushed the no-force-pgsql-credentials branch from 6d03e5e to 59f6cee Compare January 7, 2018 10:23
@techknowlogick
Copy link
Member

Closing as outdated. Please re-open as needed.

@lunny lunny removed this from the 1.x.x milestone Oct 29, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/enhancement An improvement of existing functionality type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants