本文整理汇总了Python中nodepool.cmd.nodepoolcmd.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_image_update_all
def test_image_update_all(self):
configfile = self.setup_config("node_cmd.yaml")
self._useBuilder(configfile)
self.patch_argv("-c", configfile, "image-update",
"all", "fake-image1")
nodepoolcmd.main()
self.assert_images_listed(configfile, 1)
示例2: test_delete_now
def test_delete_now(self):
configfile = self.setup_config('node.yaml')
pool = self.useNodepool(configfile, watermark_sleep=1)
self.useBuilder(configfile)
# (Shrews): This is a hack to avoid a race with the DeletedNodeWorker
# thread where it may see that our direct call to NodeDeleter.delete()
# has changed the node state to DELETING and lock the node during the
# act of deletion, but *after* the lock znode child has been deleted
# and *before* kazoo has fully removed the node znode itself. This race
# causes the rare kazoo.exceptions.NotEmptyError in this test because
# a new lock znode gets created (that the original delete does not see)
# preventing the node znode from being deleted.
pool.delete_interval = 5
pool.start()
self.waitForImage('fake-provider', 'fake-image')
nodes = self.waitForNodes('fake-label')
self.assertEqual(len(nodes), 1)
# Assert one node exists and it is node 1 in a ready state.
self.assert_listed(configfile, ['list'], 0, nodes[0].id, 1)
self.assert_nodes_listed(configfile, 1, zk.READY)
# Delete node
self.patch_argv('-c', configfile, 'delete', '--now', nodes[0].id)
nodepoolcmd.main()
self.waitForNodeDeletion(nodes[0])
# Assert the node is gone
self.assert_listed(configfile, ['list'], 0, nodes[0].id, 0)
示例3: test_dib_image_update
def test_dib_image_update(self):
configfile = self.setup_config("node_dib.yaml")
self._useBuilder(configfile)
self.patch_argv("-c", configfile, "image-update",
"fake-dib-provider", "fake-dib-image")
nodepoolcmd.main()
self.assert_images_listed(configfile, 1)
示例4: test_image_build
def test_image_build(self):
configfile = self.setup_config('node_dib.yaml')
self._useBuilder(configfile)
self.patch_argv("-c", configfile, "image-build", "fake-dib-diskimage")
nodepoolcmd.main()
self.assert_listed(configfile, ['dib-image-list'], 4, 'ready', 1)
示例5: test_alien_image_list_empty
def test_alien_image_list_empty(self):
configfile = self.setup_config("node.yaml")
self.useBuilder(configfile)
self.waitForImage('fake-provider', 'fake-image')
self.patch_argv("-c", configfile, "alien-image-list")
nodepoolcmd.main()
self.assert_alien_images_empty(configfile)
示例6: test_dib_image_build_pause
def test_dib_image_build_pause(self):
configfile = self.setup_config('node_diskimage_pause.yaml')
self.useBuilder(configfile)
self.patch_argv("-c", configfile, "image-build", "fake-image")
with testtools.ExpectedException(Exception):
nodepoolcmd.main()
self.assert_listed(configfile, ['dib-image-list'], 1, 'fake-image', 0)
示例7: test_dib_snapshot_image_update_all
def test_dib_snapshot_image_update_all(self):
configfile = self.setup_config("node_dib_and_snap.yaml")
self.patch_argv("-c", configfile, "image-update",
"all", "fake-dib-image")
nodepoolcmd.main()
self.wait_for_threads()
self.assert_images_listed(configfile, 2)
示例8: test_snapshot_image_update
def test_snapshot_image_update(self):
configfile = self.setup_config("node.yaml")
self.patch_argv("-c", configfile, "image-update",
"fake-provider", "fake-image")
nodepoolcmd.main()
self.wait_for_threads()
self.assert_images_listed(configfile, 1)
示例9: test_image_delete_invalid
def test_image_delete_invalid(self):
configfile = self.setup_config("node_cmd.yaml")
self.patch_argv("-c", configfile, "image-delete",
"--provider", "invalid-provider",
"--image", "invalid-image",
"--build-id", "invalid-build-id",
"--upload-id", "invalid-upload-id")
nodepoolcmd.main()
示例10: test_job_delete
def test_job_delete(self):
configfile = self.setup_config('node.yaml')
self.patch_argv("-c", configfile, "job-create", "fake-job",
"--hold-on-failure", "1")
nodepoolcmd.main()
self.assert_listed(configfile, ['job-list'], 2, 1, 1)
self.patch_argv("-c", configfile, "job-delete", "1")
nodepoolcmd.main()
self.assert_listed(configfile, ['job-list'], 0, 1, 0)
示例11: test_dib_snapshot_image_update
def test_dib_snapshot_image_update(self):
configfile = self.setup_config("node_dib_and_snap.yaml")
self.patch_argv("-c", configfile, "image-update",
"fake-provider1", "fake-dib-image")
nodepoolcmd.main()
self.patch_argv("-c", configfile, "image-update",
"fake-provider2", "fake-dib-image")
nodepoolcmd.main()
self.assert_images_listed(configfile, 2)
示例12: test_alien_image_list_fail
def test_alien_image_list_fail(self):
def fail_list(self):
raise RuntimeError('Fake list error')
self.useFixture(fixtures.MonkeyPatch('nodepool.fakeprovider.FakeList'
'.list', fail_list))
configfile = self.setup_config("node_cmd.yaml")
self.patch_argv("-c", configfile, "alien-image-list")
nodepoolcmd.main()
示例13: assert_listed
def assert_listed(self, configfile, cmd, col, val, count):
self.patch_argv("-c", configfile, *cmd)
with mock.patch('prettytable.PrettyTable.add_row') as m_add_row:
nodepoolcmd.main()
rows_with_val = 0
# Find add_rows with the status were looking for
for args, kwargs in m_add_row.call_args_list:
row = args[0]
if row[col] == val:
rows_with_val += 1
self.assertEquals(rows_with_val, count)
示例14: assert_images_listed
def assert_images_listed(self, configfile, image_cnt, status="ready"):
self.patch_argv("-c", configfile, "image-list")
with mock.patch('prettytable.PrettyTable.add_row') as m_add_row:
nodepoolcmd.main()
images_with_status = 0
# Find add_rows with the status were looking for
for args, kwargs in m_add_row.call_args_list:
row = args[0]
status_column = 7
if row[status_column] == status:
images_with_status += 1
self.assertEquals(images_with_status, image_cnt)
示例15: test_image_delete
def test_image_delete(self):
configfile = self.setup_config("node.yaml")
self.useBuilder(configfile)
self.waitForImage('fake-provider', 'fake-image')
image = self.zk.getMostRecentImageUpload('fake-image', 'fake-provider')
self.patch_argv("-c", configfile, "image-delete",
"--provider", "fake-provider",
"--image", "fake-image",
"--build-id", image.build_id,
"--upload-id", image.id)
nodepoolcmd.main()
self.waitForUploadRecordDeletion('fake-provider', 'fake-image',
image.build_id, image.id)