-
Notifications
You must be signed in to change notification settings - Fork 16
Bug "Copy Image Not Working #146" resolved. #147
Conversation
- __get_ceph_image_name --> replaced with get_ceph_image_name_from_project
- images is flattened
slightly off-topic but, @chemistry-sourabh can we run travis in a way so that the build doen't stop right after pep8 failures? |
@naved001 that is how This is vaguely hinted at here: https://docs.travis-ci.com/user/customizing-the-build#Breaking-the-Build |
You could run pep8 locally on your machine. Also, if you look at the Travis logs, you'll notice that the pep8 error is saying that the line is too long (over 79 characters) in certain places. So if you format it right and break it into multiple lines it should be fine. Other than that, you could setup your text editor to remove white spaces, warn you when you go over the character limit per line, and also convert your tabs to spaces. Search for "your-text-editor for python development" |
pep8 does not complain in my local machine, but still complaining here. |
hmm, that's weird. running it like how the ci runs it |
@@ -29,6 +29,7 @@ | |||
NEW_SNAP_NAME = _cfg.tests.new_snap_name | |||
NOT_EXIST_IMG_NAME = _cfg.tests.not_exist_img_name | |||
NOT_EXIST_SNAP_NAME = _cfg.tests.not_exist_snap_name | |||
ING2 = _cfg.tests.IMAGE2_NAME_PARAMETER |
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.
should be IMG2, and also you would need to put this in the config file if you are doing _cfg.tests.something
.
But I think for the purpose of this test, you can get rid of this constant from here, and just generate a random string in the setup of your test. Something like this would work
import uuid
img2 = uuid.uuid4()
@naved001 @chemistry-sourabh Can somebody please take a look at the TestCopyImage and let me know what I missed in SETUP or TearDown? I think RunTest is correct. Manually (using the command bmi cp srcPrj img1 desPrj img2), I can make a copy of img1 and use that to provision a node. Appreciate it in advance. |
time.sleep(constants.HIL_CALL_TIMEOUT) | ||
|
||
def tearDown(self): | ||
self.good_bmi.deprovision(NODE_NAME, NETWORK, NIC) |
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.
no need to deprovision because you didn't provision in the setup()
self.good_bmi = BMI(CORRECT_HIL_USERNAME, CORRECT_HIL_PASSWORD, | ||
PROJECT) | ||
self.good_bmi.import_ceph_image(EXIST_IMG_NAME) | ||
img2 = uuid.uuid4() |
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.
this should be self.img2 = uuid.uuid4()
, then it will be available in runTest
and tearDown
. And to call it you need to write self.img2
you should break when you find a match.
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.
@chemistry-sourabh suggests that you should also do a check in ceph to make sure that the copied image is present.
if img2 == image: | ||
exists_image = True | ||
self.assertTrue(exists_image) | ||
time.sleep(constants.HIL_CALL_TIMEOUT) |
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 also remove this because we aren't provisioning.
Provisioning and deprovisioning make calls to hil
that can take some time, which is why we have that sleep
call.
self.db.project.delete_with_name(PROJECT) | ||
self.db.close() | ||
self.good_bmi.shutdown() | ||
time.sleep(constants.HIL_CALL_TIMEOUT) |
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.
time.sleep
not required.
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.
@naved001 @chemistry-sourabh
Thanks,
I applied your comments, except checking the ceph to see if the image exists. I'll do it soon and let you know the result.
Hopefully the comments we made should fix the test! |
@chemistry-sourabh @apoorvemohan P.S) please ignore the pep8 error. Can somebody please take a look, thanks! |
@nasibehteimouri you need to fix the pep8 so that the tests run in Travis. Please fix the pep8 so that we can look into this. |
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.
Small Nits
Could you please add a docstring to the copy_image function also.
Also don't forget to squash the commits
@@ -2,6 +2,7 @@ | |||
|
|||
import time | |||
import unittest | |||
import uuid |
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 guess you can remove the import
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.
done.
self.good_bmi = BMI(CORRECT_HIL_USERNAME, CORRECT_HIL_PASSWORD, | ||
PROJECT) | ||
self.good_bmi.import_ceph_image(EXIST_IMG_NAME) | ||
self.img2 = 'img2' |
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.
Can you make this a constant similar to PROJECT, EXIST_IMG_NAME, etc.
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 about it. I think it must be defined in CLI. Following is the list of variables available in CLI. We should ask them to add a new variable like IMG2 for us.
- picasso_url
- correct_hil_username
- correct_hil_password
- incorrect_hil_password
- node_name
- nic
- project
- network
- exist_img_name
- new_snap_name
- not_exist_snap_name
- not_exist_img_name
_cfg.iscsi.password) as fs: | ||
img_id = self.good_bmi.get_ceph_image_name_from_project( | ||
self.img2, PROJECT) | ||
fs.get_image(img_id) |
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 am not 100% sure this will work. What if the image is not found ? As far as I know the test won't fail. You will need to fail the test if an exception is raised.
I will recommend testing it first. Try deleting the image before the get_image and see if the test fails. If it does then no issues.
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.
Tried and failed. So, there is no issue about it.
@@ -13,6 +13,8 @@ | |||
from ims.database.database import Database | |||
from ims.einstein.operations import BMI | |||
|
|||
IMG2 = 'img2' | |||
|
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.
Could you please move this to the chunk where EXIST_IMG_NAME, etc constants are defined ?
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 didnt address this
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 forgot to add the docstring to the copy_image function
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.
nits
ims/einstein/operations.py
Outdated
@@ -560,17 +560,31 @@ def get_node_ip(self, node_name): | |||
|
|||
@log | |||
def copy_image(self, img1, dest_project, img2=None): | |||
""" | |||
Create a flatten copy of a src image in DB |
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.
Create a deep copy of src image
ims/einstein/operations.py
Outdated
Create a flatten copy of a src image in DB | ||
|
||
:param img1: Name of src image | ||
:param dest_project: where the destination image will be created |
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.
name of the project where the destination image will be created
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.
LGTM. note to whoever merges this, please squash and merge.
@chemistry-sourabh ping |
6de8349
to
b44141a
Compare
ims/einstein/operations.py
Outdated
self.fs.snap_image(ceph_name, constants.DEFAULT_SNAPSHOT_NAME) | ||
self.fs.snap_protect(ceph_name, constants.DEFAULT_SNAPSHOT_NAME) |
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.
@nasibehteimouri I think this line is the issue.
Since the image's snapshot is not protected it is failing as the remove image is not able to unprotect the snapshot
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.
@nasibehteimouri looks like the previous edit fixed it.
Just do the small nits and squash. Then I'll Approve
self.fs.snap_image(ceph_name, constants.DEFAULT_SNAPSHOT_NAME) | ||
self.fs.snap_protect(ceph_name, constants.DEFAULT_SNAPSHOT_NAME) | ||
|
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.
Remove this
@@ -13,6 +13,8 @@ | |||
from ims.database.database import Database | |||
from ims.einstein.operations import BMI | |||
|
|||
IMG2 = 'img2' | |||
|
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 didnt address this
@chemistry-sourabh @nasibehteimouri We need this urgently. Could guys work on merging this? |
@nasibehteimouri can you please address the required changes so that we can merge this for @apoorvemohan ? Also I think you will need to rebase this |
@chemistry-sourabh you asked for "img2" to be defined like other constant. If so, it is impossible or at least I cannot do this. please check out here (https://github.com/CCI-MOC/ims/blob/master/docs/testing.md). It says that "The current values that are available in our CI are bellow and Let us know if your test cases need additional variables". (IMG2 must be added in CI and I cannot do this). picasso_url |
@nasibehteimouri sorry to confuse you. I meant to move IMG2 to the constants section in the same file (in the area below config.get() ) Also I think you screwed up the rebase. You did a merge instead of rebase. So first undo the merge and rebase. @xuhang57 can you please help her with this also. |
34ffd20
to
42cc2b7
Compare
@chemistry-sourabh @apoorvemohan thanks for making it more clear. I relocate img2 and now it is defined in the constant part of the file. sorry for the merge! Did un-do it and rebased. |
@chemistry-sourabh @apoorvemohan I REALLY do not know why CI fails, all tests pass on my local machine without any failures. I observed the same here and not know why still CI fails! nothing has changed compared to the last time which successfully finished. Now, I only defined img2 in line 33 instead of 16! (ims/tests/integration/einstein/test_operation.py). |
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.
Everything else LGTM!
Fix CI and you should be good
@@ -29,7 +30,7 @@ | |||
NEW_SNAP_NAME = _cfg.tests.new_snap_name | |||
NOT_EXIST_IMG_NAME = _cfg.tests.not_exist_img_name | |||
NOT_EXIST_SNAP_NAME = _cfg.tests.not_exist_snap_name | |||
|
|||
IMG2 = 'img2' | |||
|
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.
There should be one more blank line here that is why CI failed in pep8.
1e7e911
to
8839eb7
Compare
@chemistry-sourabh Thank. I think it is ready now. |
@apoorvemohan you can press the magic button whenever you want! @nasibehteimouri congratulations on your first PR |
@chemistry-sourabh github says this branch is out-of-date with the base branch. Should this be rebased before merging? There's also the "Update branch" button |
Its fine. There is no conflict, so rebase is not required. |