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
Dbixdpnc #165
Dbixdpnc #165
Conversation
the test suite protests heavily |
- database config loading via Config::IniFiles - removed deps on Config::Tiny and DBIx::Class::Schema::Config - connect_db() moved from Utils.pm to Schema.pm - added enviromental variable OPENQA_DATABASE_CONFIG to specify path to database ini file - used this for tests via OpenQA::Test::Case module
Conflicts: lib/OpenQA/Schema/Schema.pm
tests access to config file should be fixed now |
my %ini; | ||
# print("ENV{OPENQA_DATABASE_CONFIG}=$ENV{OPENQA_DATABASE_CONFIG}\n"); | ||
tie %ini, 'Config::IniFiles', ( -file => $ENV{OPENQA_DATABASE_CONFIG} || $configname ); | ||
$schema=__PACKAGE__->connect($ini{$mode}); |
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.
as I just documented the use of OPENQA_CONFIG (see #171), why did you change?
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.
oh, I see, sorry, did not noted your change before pull request. I did change it because from the code I had an impression that OPENQA_CONFIG is only for openqa.ini. It was also originaly done because of the test scripts, which, if in deeper level, could not find the database.ini file ../lib (../../lib was needed). Since in the OpenQA::Test::Case was already a OPENQA_CLIENT_CONFIG variable, it seemed natural to have another independent path for database.ini, in something like OPENQA_DATABASE_CONFIG.
If you think it is better as it was described in the documentation, I can change it to derive from OPENQA_CONFIG, but I still think, since we have already independent OPENQA_CLIENT_CONFIG, the database.ini may be justified to have its own env variable.
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 would rather drop the OPENQA_CLIENT_CONFIG than having a variable per file
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.
That's also possibility, but since it will restrict all ini files in one directory (assuming same logic for workers.ini as well), we will need to copy/link openqa.ini and database.ini into t/data directory, and also move lib/openqa.ini and lib/database.ini into etc/openqa. Is that ok to do so?
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.
also this will force all configs except openqa.ini to have always same names, maybe we should make this so also for openqa.ini and put only the dirname into the OPENQA_CONFIG ?
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.
copying, or more likely linking to t/data is needed because of t/data/client.conf. And since all cfg files have to have same directory path now, they must be present there too.
Second comment: I did not say same dirname, but same config name. While you can specify whole pathname (dir+file name) in OPENQA_CONFIG for openqa.ini, the other files have fixed names (defaults, and same directory as OPENQA_CONFIG). So I think it would be better to have all configs on same standing.
Deciding at runtime seems possible, but not so nice, since one have to check whether OPENQA_CONFIG is file or directory everytime any config file needs to be loaded. On the other hand it would make it backward compatible... But then it also dangerously resemble the idea of combining OPENQA_CONFIG and OPENQA_DATABASE_CONFIG, not sure what coolo would think about that, concerning documentation and such... :)
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.
copying, or more likely linking to t/data is needed because of t/data/client.conf. And since all cfg files have to have same directory path now, they must be present there too.
Yeah, but is it needed? I don't think they are used anywhere in tests.
Second comment: I did not say same dirname, but same config name. While you can specify whole pathname (dir+file name) in OPENQA_CONFIG for openqa.ini, the other files have fixed names (defaults, and same directory as OPENQA_CONFIG). So I think it would be better to have all configs on same standing.
Aha, I understood that as a same name (ie. everything called openqa.ini) which didn't make sense to me. Fixed name it is then.
Deciding at runtime seems possible, but not so nice, since one have to check whether OPENQA_CONFIG is file or directory everytime any config file needs to be loaded.
AFAIK they are loaded once on startup, I don't see where the problem is.
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.
Yeah, but is it needed? I don't think they are used anywhere in tests.
yes, it is needed, for example t/api/06-products.t needs database.ini
AFAIK they are loaded once on startup, I don't see where the problem is.
It could of course be done, but I think it is still clearer, in code, documentation and usage to have only one meaning for OPENQA_CONFIG. The only problem is backward compatibility..
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.
Yeah, but is it needed? I don't think they are used anywhere in tests.
yes, it is needed, for example t/api/06-products.t needs database.ini
Ah right, by the very same thing you are trying to get rid of I suppose
(Schema::Config). I wasn't paying attention and it is hidden deep. :)
I expected tests to be self contained and if needed, database.ini would be
already there.
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.
Not sure what you mean by they would already be there, I think simply linking the ini files from etc/openqa (where lib/database.ini and lib/openq.ini would be moved too) would make tests work as they do now, which means to also test the project's ini files validity. If later some specific test needs special ini file(s) just for itself, it can have them in some another t/data like directory (again linking the ones that need not to be specific).
Also, what do you think about this solution: |
whatever you do: document it. and as you document it, you will notice how silly it is :) |
I don't really think so, but in any case, I think I'd rather spare myself the effort :) |
- moved openqa.ini and database.ini lib -> etc/openqa
Conflicts: script/worker
@@ -37,7 +36,10 @@ sub new { | |||
} | |||
|
|||
if ($args{api}) { | |||
for my $file ($ENV{OPENQA_CLIENT_CONFIG}||undef, glob('~/.config/openqa/client.conf'), '/etc/openqa/client.conf') { | |||
my @cfgpaths=('~/.config/openqa', '/etc/openqa'); | |||
@cfgpaths=($ENV{OPENQA_CONFIG},@cfgpaths) if defined $ENV{OPENQA_CONFIG}; |
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.
you can use unshift here
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 know. I am more used to this form though, and in general find it a bit more readable and self explaining.
Can change it if you insist though...
fine with me now |
I tried to rebase this, but it's too long history, so merging as is |
action #5852 - remove DBIx::Class::Schema::Config
loading database.ini via Config::IniFiles,
moving connect_db() moved from Utils.pm to Schema.pm