def test_multivm_unittest(self): project = os.path.join(testenv.topdir, 'examples', 'multivm') os.chdir(project) with env.new(): status = main(['-u', testenv.username, '-p', testenv.password, '-s', testenv.service_url, 'run', 'unittest']) assert status == 0
def setup_class(cls): args = get_common_args() args += ['-m', 'platformtest.yml', 'run', 'platformtest', '--dry-run'] with env.new(): # do not pollute test-global env status = main(args) if status != 0: raise SkipTest('Could not start platformtest app.') project, defname, instance = env.application['name'].split(':') appname = '{0}:{1}'.format(defname, instance) vms = [vm['name'] for vm in env.appdef['vms']] cls.appname = appname args = get_common_args() args += ['-m', 'platformtest.yml', 'save', appname, '-y'] with env.new(): status = main(args) if status != 0: raise SkipTest('Could not create blueprint.') project, defname, instance = env.blueprint['name'].split(':') bpname = '{0}:{1}'.format(defname, instance) cls.bpname = bpname
def test_save(self): args = get_common_args() args += ['-m', 'platformtest.yml', 'save', self.appname, '-y'] status = main(args) assert status == 0 # Re-use the API that main() has created. blueprint = env.api.get_blueprint(env.blueprint['id']) assert blueprint is not None assert blueprint['id'] == env.blueprint['id'] assert blueprint['name'] == env.blueprint['name'] assert blueprint['state'] in ('PENDING', 'SAVING', 'DONE') assert len(blueprint['vms']) == len(self.vms)
def test_ps_b(self): stdout = compat.StringIO() args = get_common_args() args += ['-m', 'platformtest.yml', 'ps', '-b'] with mock.patch('sys.stdout', stdout): status = main(args) assert status == 0 parsed = parse_ps_output(stdout.getvalue()) for project,bp,_ in parsed: if project is None and bp == self.bpname: break else: assert False, 'Blueprint not found.'
def test_ps_a(self): stdout = compat.StringIO() args = get_common_args() args += ['ps', '-a'] with mock.patch('sys.stdout', stdout): status = main(args) assert status == 0 parsed = parse_ps_output(stdout.getvalue()) for project,app,vms in parsed: if project == 'testmilltest' and app.startswith('platformtest:') \ and vms > 0: break else: assert False, 'Application not found.'
def test_multivm_acceptance(self): project = os.path.join(testenv.topdir, 'examples', 'multivm') os.chdir(project) status = main(['-u', testenv.username, '-p', testenv.password, '-s', testenv.service_url, 'run', 'acceptance']) for vm in env.application['vms']: if vm['name'] == 'web': break assert vm['name'] == 'web' ipaddr = vm['dynamicMetadata']['externalIp'] for svc in vm['suppliedServices']: basesvc = svc['baseService'] if basesvc['name'].startswith('http'): port = basesvc['portRange'] break assert basesvc['name'].startswith('http') assert status == 0 url = 'http://{0}:{1}/FrontPage'.format(ipaddr, port) fin = urllib.urlopen(url) page = fin.read() fin.close() assert 'Pyramid tutorial wiki' in page
def test_clojure(self): project = os.path.join(testenv.topdir, 'examples', 'clojure') os.chdir(project) status = main(['-u', testenv.username, '-p', testenv.password, '-s', testenv.service_url, 'run', 'platformtest']) assert status == 0
def teardown_class(cls): args = get_common_args() args += ['-m', 'platformtest.yml', '-y', 'clean', '-b'] with env.new(): main(args)
def test_images(self): args = get_common_args() args += ['run', '-m', 'platformtest.yml', 'platformtest', 'sh check_image.sh'] retval = main(args) assert retval == 0
def test_login_failed(self): status = main(['-u', testenv.username, '-p', 'invalid', '-s', testenv.service_url, 'login']) assert status != 0
def test_login_with_positional_username(self): status = main(['-p', testenv.password, '-s', testenv.service_url, 'login', testenv.username]) assert status == 0
def test_login_prompt(self): with mock.patch.multiple('testmill.console', prompt=lambda *args: testenv.username, getpass=lambda *args: testenv.password): status = main(['-s', testenv.service_url, 'login']) assert status == 0
def test_login(self): status = main(['-u', testenv.username, '-p', testenv.password, '-s', testenv.service_url, 'login']) assert status == 0