-
Notifications
You must be signed in to change notification settings - Fork 119
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
Rewrite updated_ood_portal to be Ruby #108
Conversation
How does this achieve the goal? The checksum is used to verify that the administrator has not hand-modified the ood-portal.conf Apache config. If the administrator never hand-modifies the config, the checksum will ensure that Note: because the checksum file is being made of ood-portal.conf without comments, but then is being used to check a file ood-portal.conf that contains comments, won't this new checksum always fail? So Regardless, since we are now sticking with |
Also, https://github.com/OSC/ondemand/blob/master/ood-portal-generator/ is getting more complex, and I wonder if it makes more sense to move some of this logic into the Ruby code itself. Or at least, write some minitest tests that exercise this script with different inputs and outputs to verify the desired functionality. Happy to help with test scaffolding. |
…ly support replacing update_ood_portal with Application module
@ericfranz I agree, this is getting complex enough this should be in Ruby. I am working on moving |
Completely refactored Example output:
|
@@ -12,5 +12,10 @@ class << self | |||
def root | |||
Pathname.new(__dir__).dirname | |||
end | |||
|
|||
def scl_apache |
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.
def scl_apache?
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.
Changed made.
end | ||
end | ||
|
||
def sum |
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.
def sum_path
for clarity?
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.
Change made.
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.
Added comments but it was all minor code quality suggestions or test improvements. So if you are happy and/or don't have time to make those changes I say just merge and we can make notes to improve later.
The changes are simple except the one for tests. I'll make them Tuesday at latest. The unit test either has to mock because can't assume write access to like /opt and /etc or has to be run as system tests in a container. For unit I have to at least mock file paths with Tempfile to avoid writing to inaccessible places but system tests could better stress this inside docker where we have root. |
I didn't communicate my idea for the tests well. What I was thinking was a set of tests that exercised the outside boundary of the script, without mocking any parts inside of the script. If all of the system paths can be modified using env vars (CONFIG, SUM, APACHE) the set of tests could use https://github.com/thoughtbot/climate_control and follow the pattern:
|
Following up on the idea I posed with using climate control, you would also add argv as an argument to OodPortalGenerator::Application.start("update_ood_portal", ["--detailed-exitcodes"]) |
…y only on fixtures
@ericfranz Look now. I added |
Added Rake tasks to aid in running tests from root of this project without ugly "cd" type Travis scripts |
Rewrote travis.yml to use stages so that unit tests happen before system tests and only running tests on master, tags and pull requests to avoid double testing during pull requests when the branch is on this repo. |
38f061c
to
2e36e49
Compare
Looks like getting this in Travis |
2e36e49
to
e30ccdb
Compare
e30ccdb
to
1e1af4e
Compare
Looks like |
1e1af4e
to
b1cf262
Compare
b1cf262
to
2374950
Compare
@treydock I'm happy with the changes. Ready to merge or did you want to do anything else on this first? |
@ericfranz This PR is ready to merge. |
Should resolve #100.
This changes checksum to be based on non-comments and also replacing simple
cmp
withdiff
that ignores comments.Just FYI the way OSC deploys ood-portal.conf will NOT ignore comments because we generate
/etc/ood/config/ood-portal.conf
not usingupdate_ood_portal
and then we use Puppet to put the file into correct location and no way for it to ignore comments.One flaw with this approach is changes to the comments won't even get written to as
.new
file. If I keepcmp
instead of usingdiff
then get something like this when comments change: