8000 Bug "Copy Image Not Working #146" resolved. by nasibehteimouri · Pull Request #147 · CCI-MOC/m2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 27, 2022. It is now read-only.

Bug "Copy Image Not Working #146" resolved. #147

Merged
merged 1 commit into from
Feb 10, 2018

Conversation

nasibehteimouri
Copy link
Contributor
  1. __get_ceph_image_name --> replaced with get_ceph_image_name_from_project
  2. images is flattened

@naved001
Copy link
Contributor

slightly off-topic but, @chemistry-sourabh can we run travis in a way so that the build doen't stop right after pep8 failures?

@jeremyfreudberg
Copy li 8000 nk
Member

@naved001 that is how before_script works in Travis. Anything in that section is assumed to be "setup" code that the script section relies on, so Travis thinks it is being smart by skipping everything else if setup fails

This is vaguely hinted at here: https://docs.travis-ci.com/user/customizing-the-build#Breaking-the-Build

@naved001
Copy link
Contributor
naved001 commented Sep 28, 2017

@nasibehteimouri

You could run pep8 locally on your machine.
pip install pep8 and then `pep8 <filename.py>'

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"

@nasibehteimouri
Copy link
Contributor Author

pep8 does not complain in my local machine, but still complaining here.

@naved001
Copy link
8000
Contributor
naved001 commented Sep 28, 2017

hmm, that's weird. running it like how the ci runs it find . -name \*.py -exec pep8 --ignore=E402 {} + should point out the errors.

@@ -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
Copy link
Contributor

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()

@nasibehteimouri
Copy link
Contributor Author

@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)
Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

time.sleep not required.

Copy link
Contributor Author

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.

@naved001
8000 Copy link
Contributor
naved001 commented Oct 3, 2017

Hopefully the comments we made should fix the test!

@nasibehteimouri
Copy link
Contributor Author

@chemistry-sourabh @apoorvemohan
As far as I see from the log, it seems that there is a problem with db.image.copy_image, or the way that it is called in copy_image (in operations.py). It seems that the EXIST_IMG is not found in db.

P.S) please ignore the pep8 error.

Can somebody please take a look, thanks!

@chemistry-sourabh
Copy link
Contributor

@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.

Copy link
Contributor
@chemistry-sourabh chemistry-sourabh left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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'
67ED
Copy link
Contributor

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.

Copy link
Contributor Author
@nasibehteimouri nasibehteimouri Oct 23, 2017

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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'

Copy link
Contributor

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 ?

Copy link
Contributor
F438

Choose a reason for hiding this comment

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

You didnt address this

Copy link
Contributor
@chemistry-sourabh chemistry-sourabh left a 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

Copy link
Contributor
@chemistry-sourabh chemistry-sourabh left a comment

Choose a reason for hiding this comment

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

nits

@@ -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
Copy link
Contributor

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

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
Copy link
Contributor

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

Copy link
Contributor
@naved001 naved001 left a 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.

@naved001
Copy link
Contributor

@chemistry-sourabh ping

self.fs.snap_image(ceph_name, constants.DEFAULT_SNAPSHOT_NAME)
self.fs.snap_protect(ceph_name, constants.DEFAULT_SNAPSHOT_NAME)
Copy link
Contributor

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

Copy link
Contributor
@chemistry-sourabh chemistry-sourabh left a 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)

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this

F438

@@ -13,6 +13,8 @@
from ims.database.database import Database
from ims.einstein.operations import BMI

IMG2 = 'img2'

Copy link
Contributor

Choose a reason for hiding this comment

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

You didnt address this

@apoorvemohan
Copy link
Collaborator

@chemistry-sourabh @nasibehteimouri We need this urgently. Could guys work on merging this?

@chemistry-sourabh
Copy link
Contributor
chemistry-sourabh commented Feb 8, 2018

@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

@nasibehteimouri
Copy link
Contributor Author

@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
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
"

@chemistry-sourabh
Copy link
Contributor
chemistry-sourabh commented Feb 9, 2018

@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.

@nasibehteimouri
Copy link
Contributor Author

@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.

@nasibehteimouri
Copy link
Contributor Author

@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).

Copy link
Contributor
@chemistry-sourabh chemistry-sourabh left a 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'

Copy link
Contributor

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.

@nasibehteimouri
Copy link
Contributor Author

@chemistry-sourabh Thank. I think it is ready now.

@chemistry-sourabh
Copy link
Contributor

@apoorvemohan you can press the magic button whenever you want!

@nasibehteimouri congratulations on your first PR

@naved001
Copy link
Contributor

@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

@chemistry-sourabh
Copy link
Contributor

Its fine. There is no conflict, so rebase is not required.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0