How to use run_stage method in localstack

Best Python code snippet using localstack_python

runtest.py

Source: runtest.py Github

copy

Full Screen

...10 env = TestFileEnvironment(os.path.join(here, 'test-data'))11 return env12stage_seq = ['create-node', 'setup-node', 'clean', 'update', 'update-path',13 'logs', 'query', 'activation', 'backup-update', 'backup-clear']14def run_stage(name, match):15 return match in stage_seq[stage_seq.index(name):]16def run_test(name, stage=None, ci=False, setup_node=False):17 try:18 if stage is None:19 if name:20 stage = 'clean'21 else:22 stage = 'setup-node'23 env = get_environment()24 if not name:25 name = 'functest%s.example.com' % int(time.time())26 print 'Creating node %s' % name27 print env.run('silver --yes create-node --wait %s' % name,28 expect_stderr=True)29 if run_stage(stage, 'setup-node') or setup_node:30 print 'Setting up node %s' % name31 print env.run('silver --yes setup-node %s' % name,32 expect_stderr=True)33 if run_stage(stage, 'clean'):34 print env.run('silver --yes deactivate --node=%s "*"' % name)35 print env.run('silver --yes clean-node %s' % name)36 if run_stage(stage, 'update'):37 print 'Doing update'38 result = env.run('silver --yes update "%s" %s'39 % (os.path.join(here, 'example-app'), name),40 expect_stderr=True)41 print result42 assert 'env CONFIG_COUCHDB_DB=functest' in result.stdout, result.stdout43 assert 'env CONFIG_COUCHDB_HOST=127.0.0.1:5984' in result.stdout, result.stdout44 assert 'env CONFIG_FILES=/​var/​lib/​silverlining/​apps/​functest' in result.stdout, result.stdout45 assert 'env CONFIG_PG_DBNAME=functest' in result.stdout, result.stdout46 assert 'env CONFIG_PG_HOST=' in result.stdout, result.stdout47 assert 'env CONFIG_PG_PASSWORD=' in result.stdout, result.stdout48 assert 'env CONFIG_PG_PORT=' in result.stdout, result.stdout49 assert 'env CONFIG_PG_SQLALCHEMY=postgres:/​/​postgres@/​functest' in result.stdout, result.stdout50 assert 'env CONFIG_PG_USER=www-mgr' in result.stdout, result.stdout51 assert 'env CONFIG_WRITABLE_ROOT=/​var/​lib/​silverlining/​writable-roots/​functest' in result.stdout, result.stdout52 assert 'env SILVER_VERSION=silverlining/​' in result.stdout, result.stdout53 result = env.run('silver --yes update --debug-single-process "%s" %s'54 % (os.path.join(here, 'example-app'), name),55 expect_stderr=True)56 print result57 resp = urllib.urlopen('http:/​/​%s/​update' % name).read()58 print 'Got HTTP response:\n%s' % resp59 assert ('SILVER_CANONICAL_HOSTNAME=%s' % name) in resp60 assert 'wsgi.multiprocess=True' in resp61 assert 'wsgi.multithread=True' in resp62 assert "path='' '/​update'" in resp63 resp = urllib.urlopen('http:/​/​%s/​static_file.txt' % name).read()64 print 'Got static HTTP response:\n%s' % resp65 assert resp.strip() == 'This is a test'66 resp = urllib.urlopen('http:/​/​%s/​write-root' % name).read()67 assert resp.strip().startswith('WRITABLE_ROOT='), resp68 resp = urllib.urlopen('http:/​/​%s/​test-writable.txt' % name).read()69 assert resp.strip() == 'test writable', resp70 resp = urllib.urlopen('http:/​/​%s/​test-hosted.txt' % name).read()71 assert resp.strip() == 'test hosted', resp72 if run_stage(stage, 'update-path'):73 print 'Doing update to path'74 result = env.run('silver --yes update "%s" %s/​test'75 % (os.path.join(here, 'example-app'), name),76 expect_stderr=True)77 print result78 url = 'http:/​/​%s/​test/​update' % name79 resp = urllib.urlopen(url).read()80 print 'The actual HTTP response: (%s)' % url81 print resp82 if run_stage(stage, 'logs'):83 print 'Doing log check'84 ssh('www-data', name, ['bash', '-c', 'rm /​var/​log/​silverlining/​apps/​functest/​*'])85 url = 'http:/​/​%s/​test/​update' % name86 resp = urllib.urlopen(url).read()87 text, _, _ = ssh('www-data', name,88 ['cat', '/​var/​log/​silverlining/​apps/​functest/​errors.log'],89 capture_stdout=True)90 text_lines = ''.join(text.strip().splitlines(True)[1:-1]).strip()91 assert text_lines == """\92Executed application93This is stdout94This is stderr""", repr(text_lines)95 if run_stage(stage, 'query'):96 print 'Doing query'97 result = env.run('silver --yes query %s' % name)98 print result99 assert 'Site: default-disabled' in result.stdout100 assert 'default-disabled: disabled/​' in result.stdout101 assert 'functest' in result.stdout102 assert re.search(r'functest.*?: %s/​' % name, result.stdout)103 if run_stage(stage, 'activation'):104 print env.run('silver --yes deactivate %s/​test' % name)105 print env.run('silver --yes query %s' % name)106 print env.run('silver --yes activate %s prev' % name)107 print env.run('silver --yes query %s' % name)108 if run_stage(stage, 'backup-update'):109 print env.run('silver --yes deactivate --node=%s "*"' % name)110 print env.run('silver --yes update "%s" %s'111 % (os.path.join(here, 'example-backup'), name),112 expect_stderr=True)113 url = 'http:/​/​%s/​' % name114 resp = urllib.urlopen(url).read()115 print resp116 resp = env.run('silver --yes backup %s/​ test-backup/​' % name)117 print resp118 assert 'test-backup/​mysql/​mysql.dump' in resp.files_created119 assert 'test-backup/​files/​files.tar' in resp.files_created120 if run_stage(stage, 'backup-clear'):121 print env.run('silver --yes clear %s' % name)122 resp = env.run('silver --yes backup %s/​ test-backup-cleared/​' % name)123 print resp124 assert 'test_table' not in resp.files_created['test-backup-cleared/​mysql/​mysql.dump'].bytes125 urllib.urlopen('http:/​/​'+name).read()126 resp = env.run('silver --yes backup %s/​ test-backup-bare/​' % name)127 print resp128 assert 'test_table' in resp.files_created['test-backup-bare/​mysql/​mysql.dump'].bytes129 print env.run('silver --yes clear %s' % name)130 resp = env.run('silver --yes restore test-backup-bare/​ %s' % name)131 print resp132 resp = env.run('silver --yes backup %s/​ test-backup-restored/​' % name)133 assert 'test_table' in resp.files_created['test-backup-restored/​mysql/​mysql.dump'].bytes134 finally:...

Full Screen

Full Screen

releasecheck.py

Source: releasecheck.py Github

copy

Full Screen

2from os.path import join, basename, normpath3from subprocess import check_call4def main(version, outdir):5 check_version(version, outdir)6 run_stage(['bin/​mailmap_update.py'])7 run_stage(['bin/​authors_update.py'])8 run_stage(['mkdir', '-p', outdir])9 build_release_files('bdist_wheel', 'sympy-%s-py3-none-any.whl', outdir, version)10 build_release_files('sdist', 'sympy-%s.tar.gz', outdir, version)11 run_stage(['release/​compare_tar_against_git.py', join(outdir, 'sympy-%s.tar.gz' % (version,)), '.'])12 run_stage(['release/​test_install.py', version, outdir])13 run_stage(['release/​build_docs.py', version, outdir])14 run_stage(['release/​sha256.py', version, outdir])15 run_stage(['release/​authors.py', version, outdir])16def green(text):17 return "\033[32m%s\033[0m" % text18def red(text):19 return "\033[31m%s\033[0m" % text20def print_header(color, *msgs):21 newlines = '\n'22 vline = '-' * 8023 print(color(newlines + vline))24 for msg in msgs:25 print(color(msg))26 print(color(vline + newlines))27def run_stage(cmd):28 cmdline = ' $ %s' % (' '.join(cmd),)29 print_header(green, 'running:', cmdline)30 try:31 check_call(cmd)32 except Exception as e:33 print_header(red, 'failed:', cmdline)34 raise e from None35 else:36 print_header(green, 'completed:', cmdline)37def build_release_files(cmd, fname, outdir, version):38 fname = fname % (version,)39 run_stage(['python', 'setup.py', '-q', cmd])40 src = join('dist', fname)41 dst = join(outdir, fname)42 run_stage(['mv', src, dst])43def check_version(version, outdir):44 from sympy.release import __version__ as checked_out_version45 if version != checked_out_version:46 msg = "version %s does not match checkout %s"47 raise AssertionError(msg % (version, checked_out_version))48 if basename(normpath(outdir)) != 'release-%s' % (version,):49 msg = "version %s does not match output directory %s"50 raise AssertionError(msg % (version, outdir))51if __name__ == "__main__":52 import sys...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

How To Choose The Best JavaScript Unit Testing Frameworks

JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.

A Complete Guide To CSS Container Queries

In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.

Considering Agile Principles from a different angle

In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful