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

Adding test for initial startup #849

Merged
merged 25 commits into from
Dec 20, 2016
Merged

Adding test for initial startup #849

merged 25 commits into from
Dec 20, 2016

Conversation

rob-c
Copy link
Member

@rob-c rob-c commented Oct 27, 2016

This adds a small test which actually ensures that exceptions caused by launching Ganga in a clean env are caught. Most devs (myself included) don't often startup in a clean env regularly so it's possible to break things and for them to go un-noticed as we don't remove our .gangarc and similar files very often.

@rob-c rob-c added this to the 6.2.3 milestone Oct 27, 2016
@rob-c rob-c self-assigned this Oct 27, 2016
standardSetup()
del standardSetup

def testStartUp():
Copy link
Member

Choose a reason for hiding this comment

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

Does this function replicate the calls made in the "real" startup? If yes, is there a risk that it goes out of sync? Should this rather be factored out of the real startup such that the same code can be called here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@egede Yes and No. There are some changes and extra args which need to be passed here...
I'm exploring importing the ./bin/ganga file and using the code there I'm just exploring why this works when I test it but not in Jenkins atm. I can 'make' it work but I'm wondering if that's correct.

@rob-c
Copy link
Member Author

rob-c commented Oct 27, 2016

OK, I've improved the test to not break things. I've also moved some common code out so that the code being tested is the code being used in the ganga executable during startup.

@rob-c
Copy link
Member Author

rob-c commented Oct 27, 2016

I've also added some checks to see if the .gangarc, .ganga.log and gangadir\... are all created correctly as appropriate.

@rob-c rob-c changed the base branch from develop to 6.3-features October 28, 2016 12:53
@mesmith75 mesmith75 modified the milestones: 6.3.0, 6.2.3 Nov 7, 2016
@mesmith75
Copy link
Contributor

retest this please

@rob-c rob-c changed the base branch from 6.3-features to develop November 18, 2016 19:18
@mesmith75 mesmith75 modified the milestones: 6.3.1, 6.3.0 Dec 1, 2016
Fixing minor bug from corrections
# Import GPI and run Ganga
from Ganga.GPI import *
setupGanga()
Ganga.Runtime._prog.run()
Copy link
Contributor

Choose a reason for hiding this comment

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

This didn't work for me without bringing back the import Ganga.Runtime

Copy link
Member Author

@rob-c rob-c Dec 12, 2016

Choose a reason for hiding this comment

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

How so? I'm curious what env causes problems as it could be a difference between my setup and LHCb vanilla

Copy link
Contributor

Choose a reason for hiding this comment

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

Traceback (most recent call last):
  File "/afs/cern.ch/user/m/masmith/cmtuser/GANGA/GANGA_HEAD/install/ganga/bin/ganga", line 62, in <module>
    Ganga.Runtime._prog.run()
NameError: name 'Ganga' is not defined

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, looks like the standardSetup doesn't seem to take correctly and the test is over-compensating for this by inserting ganga into the python path. I'll see if I can make some changes to the standard startup script to fix this.
(I think we should really be using the __file__ property rather than the argv to determine where this file is...)

Copy link
Member Author

Choose a reason for hiding this comment

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

@mesmith75 How about now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Still the same problem

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I'll try importing Ganga.Runtime then, strange how I can't seem to be able to reproduce this and the tests pass...

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, maybe I have done something peculiar to my setup...

Copy link
Member Author

Choose a reason for hiding this comment

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

Does it work now? I decided to be explicit and import the _prog after it's been initialized

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that works.

@mesmith75
Copy link
Contributor

Spoke too soon - it has messed up something for creating jobs:

Traceback (most recent call last):
  File "/afs/cern.ch/user/m/masmith/cmtuser/GANGA/GANGA_HEAD/install/ganga/bin/ganga", line 63, in <module>
    _prog.run()
  File "/afs/cern.ch/user/m/masmith/cmtuser/GANGA/GANGA_HEAD/install/ganga/python/Ganga/Runtime/bootstrap.py", line 1058, in run
    execfile(script, local_ns)
  File "job.py", line 20, in <module>
    j = Job()
NameError: name 'Job' is not defined

@rob-c
Copy link
Member Author

rob-c commented Dec 13, 2016

@mesmith75 OK now I need to know how you reproduced this? I am able to launch an IPython prompt are you trying to do something different than use the interactive mode?

@egede
Copy link
Member

egede commented Dec 13, 2016

@mesmith75 @rob-c This works for me. It starts Ganga and I can create a job. Tested both in a plain environment and in an LHCb environment.

@rob-c
Copy link
Member Author

rob-c commented Dec 13, 2016

@egede I discovered this effects running scripts so I'm looking into it.

@rob-c
Copy link
Member Author

rob-c commented Dec 13, 2016

OK, fixed that and solved the mystery of how user scripts were run from within the GPI.
I spent nearly 3 years trying to work out where the GPI was imported for them and it turns out it was imported in the bin/ganga script's global scope and was then pulled from this elsewhere.

@mesmith75
Copy link
Contributor

I'm afraid I still get errors, starting ganga with a job script: ganga job.py

Traceback (most recent call last):
  File "/afs/cern.ch/user/m/masmith/cmtuser/GANGA/GANGA_HEAD/install/ganga/bin/ganga", line 65, in <module>
    log(Ganga.Runtime._prog.options.force_loglevel, err)
NameError: name 'Ganga' is not defined

It is fine to start ganga without the script argument

Fixing _prog import in exceptions
@rob-c
Copy link
Member Author

rob-c commented Dec 13, 2016

@mesmith75 I get no problems running with a test job j=Job();j.submit()
I've fixed the Ganga bug you've mentioned above, can you let me know if there are any other issues?

@mesmith75
Copy link
Contributor

Thanks, that works fine.

@rob-c
Copy link
Member Author

rob-c commented Dec 19, 2016

Any objections to merging this for 6.3.1?

Copy link
Contributor

@alexanderrichards alexanderrichards left a comment

Choose a reason for hiding this comment

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

Some comments/questions

except GangaException as err:
log(Ganga.Runtime._prog.options.force_loglevel, err)
from Ganga.Runtime import _prog
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we import this in two locations, within the try and the except rather than at the top?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I think your correct, this should be a single import

logfile, maxBytes=logfile_size, backupCount=1)
with open(logfile, 'w'):
pass
new_file_handler = logging.handlers.RotatingFileHandler(logfile, maxBytes=logfile_size, backupCount=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question, why do we need to open the file here and immediately close it?

Copy link
Member Author

Choose a reason for hiding this comment

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

To guarantee that the file has been created. This seems to get rid of a lot of the problems that the rotating log file handler seems to have on one system where I was able to reproduce the problem that the stdout got spammed with lots of failed to flush to disk errors. It's a strange bug that is difficult to reproduce and this at least mitigates it. I'll add a doc string

@mesmith75
Copy link
Contributor

Do we still want this in for 6.3.1?

@rob-c
Copy link
Member Author

rob-c commented Dec 20, 2016

@mesmith75 Yes please if we can

@mesmith75
Copy link
Contributor

ok. If you could reply to @alexanderrichards review then we can stick it in.

@rob-c
Copy link
Member Author

rob-c commented Dec 20, 2016

updated

Copy link
Contributor

@mesmith75 mesmith75 left a comment

Choose a reason for hiding this comment

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

ok

@mesmith75
Copy link
Contributor

If we are happy, let's merge this and release the next version.

@mesmith75 mesmith75 merged commit 7520054 into develop Dec 20, 2016
@mesmith75 mesmith75 deleted the testingIntialStartUp branch December 20, 2016 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants