Best Python code snippet using localstack_python
test_db_benchmark.py
Source: test_db_benchmark.py
1import sys2import json3import time4from queue import Full, Empty5import requests6import multiprocessing7from collections import namedtuple8from cryptoconditions import crypto9from bigchaindb.common.transaction import Transaction, Asset, Fulfillment10from bigchaindb.common.util import gen_timestamp11from bigchaindb import Bigchain12CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key'))13host = "localhost"14port = "9984"15db_port = "28015"16num_clients = 5617count = 1000018create_queue = multiprocessing.Queue(maxsize=count)19transfer_queue = multiprocessing.Queue(maxsize=count)20b = Bigchain()21def generate_keypair():22 return CryptoKeypair(23 *(k.decode() for k in crypto.ed25519_generate_key_pair()))24def create_transfer(p_num):25 print(p_num, ":create_transfer start")26 while True:27 alice, bob = generate_keypair(), generate_keypair()28 asset = Asset(data={'money': 'RMB'}, data_id='20170628150000', divisible=True)29 metadata = {'planet': 'earth'}30 tx_create = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=metadata, asset=asset)31 tx_create = tx_create.sign([alice.private_key])32 try:33 create_queue.put(tx_create, False)34 except Full:35 print(p_num, ":create_queue full", create_queue.qsize())36 break37 cid = 038 condition = tx_create.to_dict()['transaction']['conditions'][cid]39 inputs = Fulfillment.from_dict({40 'fulfillment': condition['condition']['details'],41 'input': {42 'cid': cid,43 'txid': tx_create.to_dict()['id'],44 },45 'owners_before': condition['owners_after'],46 })47 asset = Asset.from_dict(tx_create.to_dict()['transaction']['asset'])48 tx_transfer = Transaction.transfer([inputs], [([bob.public_key], 1)], asset)49 tx_transfer = tx_transfer.sign([alice.private_key])50 try:51 transfer_queue.put(tx_transfer, False)52 except Full:53 print(p_num, ":transfer_queue full")54 break55def post_create(p_num):56 while True:57 headers = {'content-type': 'application/json'}58 url = 'http://{}:{}/uniledger/v1/transaction/fastCreateOrTransferTx'.format(host, port)59 try:60 value = create_queue.get(False)61 except Empty:62 if create_queue.qsize() > 0:63 # print(p_num, ":create_queue not actually empty", create_queue.qsize())64 continue65 print(p_num, ":create_queue empty", create_queue.qsize())66 break67 b.write_transaction(value)68 # value = json.dumps(value.to_dict())69 # requests.post(url, data=value, headers=headers)70def post_transfer(p_num):71 while True:72 headers = {'content-type': 'application/json'}73 url = 'http://{}:{}/uniledger/v1/transaction/fastCreateOrTransferTx'.format(host, port)74 try:75 value = transfer_queue.get(False)76 except Empty:77 if transfer_queue.qsize() > 0:78 # print(p_num, ":transfer_queue not actually empty", transfer_queue.qsize())79 continue80 print(p_num, ":transfer_queue empty", transfer_queue.qsize())81 break82 b.write_transaction(value)83 # value = json.dumps(value.to_dict())84 # requests.post(url, data=value, headers=headers)85if __name__ == '__main__':86 if len(sys.argv) > 1:87 count = int(sys.argv[1])88 create_queue = multiprocessing.Queue(maxsize=count)89 transfer_queue = multiprocessing.Queue(maxsize=count)90 # create_queue and transfer_queue91 print("step 1 :generate keypair, create tx(create_queue), transfer(transfer_queue)")92 for x in range(num_clients):93 p = multiprocessing.Process(target=create_transfer, args=(x,))94 p.start()95 # wait for 'Full'96 while True:97 if transfer_queue.full():98 break99 time.sleep(1)100 print("m :transfer qsize:", transfer_queue.qsize())101 input("Press enter key to continue...")102 # post create103 print("step 2 :post create tx ,please wait for all create tx valid")104 transfer_start = gen_timestamp()105 for x in range(num_clients):106 p = multiprocessing.Process(target=post_create, args=(x,))107 p.start()108 # wait for post create109 while True:110 if create_queue.empty():111 break112 time.sleep(1)113 print("m :create qsize:", create_queue.qsize())114 transfer_end = gen_timestamp()115 transfer_cost = (int(transfer_end) - int(transfer_start)) / 1000116 print("m :transfer_start:", transfer_start)117 print("m :transfer_end:", transfer_end)118 print("m :transfer_cost:", transfer_cost)119 #120 input("Press enter key to continue...")121 BANNER = """122 *******************123 * ready, go! *124 *******************125 """126 print(BANNER)127 # post transfer128 print("step 3 :post transfer tx ,please wait for all transfer tx valid")129 transfer_start = gen_timestamp()130 for x in range(num_clients):131 p = multiprocessing.Process(target=post_transfer, args=(x,))132 p.start()133 # wait for post transfer134 while True:135 if transfer_queue.empty():136 break137 time.sleep(1)138 print("m :transfer qsize:", transfer_queue.qsize())139 transfer_end = gen_timestamp()140 transfer_cost = (int(transfer_end) - int(transfer_start)) / 1000141 print("m :transfer_start:", transfer_start)142 print("m :transfer_end:", transfer_end)...
test_transfer_benchmark.py
Source: test_transfer_benchmark.py
1import sys2import json3import time4from queue import Full, Empty5import requests6import multiprocessing7from collections import namedtuple8from cryptoconditions import crypto9from bigchaindb.common.transaction import Transaction, Asset, Fulfillment10from bigchaindb.common.util import gen_timestamp11CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key'))12host = "localhost"13port = "9984"14db_port = "28015"15num_clients = 5616count = 1000017create_queue = multiprocessing.Queue(maxsize=count)18transfer_queue = multiprocessing.Queue(maxsize=count)19def generate_keypair():20 return CryptoKeypair(21 *(k.decode() for k in crypto.ed25519_generate_key_pair()))22def create_transfer(p_num):23 print(p_num, ":create_transfer start")24 while True:25 alice, bob = generate_keypair(), generate_keypair()26 asset = Asset(data={'money': 'RMB'}, data_id='20170628150000', divisible=True)27 metadata = {'planet': 'earth'}28 tx_create = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=metadata, asset=asset)29 tx_create = tx_create.sign([alice.private_key])30 try:31 create_queue.put(tx_create, False)32 except Full:33 print(p_num, ":create_queue full", create_queue.qsize())34 break35 cid = 036 condition = tx_create.to_dict()['transaction']['conditions'][cid]37 inputs = Fulfillment.from_dict({38 'fulfillment': condition['condition']['details'],39 'input': {40 'cid': cid,41 'txid': tx_create.to_dict()['id'],42 },43 'owners_before': condition['owners_after'],44 })45 asset = Asset.from_dict(tx_create.to_dict()['transaction']['asset'])46 tx_transfer = Transaction.transfer([inputs], [([bob.public_key], 1)], asset)47 tx_transfer = tx_transfer.sign([alice.private_key])48 try:49 transfer_queue.put(tx_transfer, False)50 except Full:51 print(p_num, ":transfer_queue full")52 break53def post_create(p_num):54 while True:55 headers = {'content-type': 'application/json'}56 url = 'http://{}:{}/uniledger/v1/transaction/fastCreateOrTransferTx'.format(host, port)57 try:58 value = create_queue.get(False)59 except Empty:60 if create_queue.qsize() > 0:61 # print(p_num, ":create_queue not actually empty", create_queue.qsize())62 continue63 print(p_num, ":create_queue empty", create_queue.qsize())64 break65 value = json.dumps(value.to_dict())66 requests.post(url, data=value, headers=headers)67def post_transfer(p_num):68 while True:69 headers = {'content-type': 'application/json'}70 url = 'http://{}:{}/uniledger/v1/transaction/fastCreateOrTransferTx'.format(host, port)71 try:72 value = transfer_queue.get(False)73 except Empty:74 if transfer_queue.qsize() > 0:75 # print(p_num, ":transfer_queue not actually empty", transfer_queue.qsize())76 continue77 print(p_num, ":transfer_queue empty", transfer_queue.qsize())78 break79 value = json.dumps(value.to_dict())80 requests.post(url, data=value, headers=headers)81if __name__ == '__main__':82 if len(sys.argv) > 1:83 count = int(sys.argv[1])84 create_queue = multiprocessing.Queue(maxsize=count)85 transfer_queue = multiprocessing.Queue(maxsize=count)86 # create_queue and transfer_queue87 print("step 1 :generate keypair, create tx(create_queue), transfer(transfer_queue)")88 for x in range(num_clients):89 p = multiprocessing.Process(target=create_transfer, args=(x,))90 p.start()91 # wait for 'Full'92 while True:93 if transfer_queue.full():94 break95 time.sleep(1)96 print("m :transfer qsize:", transfer_queue.qsize())97 input("Press enter key to continue...")98 # post create99 print("step 2 :post create tx ,please wait for all create tx valid")100 for x in range(num_clients):101 p = multiprocessing.Process(target=post_create, args=(x,))102 p.start()103 # wait for post create104 while True:105 if create_queue.empty():106 break107 time.sleep(1)108 print("m :create qsize:", create_queue.qsize())109 #110 input("Press enter key to continue...")111 BANNER = """112 *******************113 * ready, go! *114 *******************115 """116 print(BANNER)117 # post transfer118 print("step 3 :post transfer tx ,please wait for all transfer tx valid")119 transfer_start = gen_timestamp()120 for x in range(num_clients):121 p = multiprocessing.Process(target=post_transfer, args=(x,))122 p.start()123 # wait for post transfer124 while True:125 if transfer_queue.empty():126 break127 time.sleep(1)128 print("m :transfer qsize:", transfer_queue.qsize())129 transfer_end = gen_timestamp()130 transfer_cost = (int(transfer_end) - int(transfer_start)) / 1000131 print("m :transfer_start:", transfer_start)132 print("m :transfer_end:", transfer_end)...
create_fcb01_jms.py
Source: create_fcb01_jms.py
...16create_qcf(mq,'FCBSITOltpQM1','jms/FCBSITOltpQM1','FCBSITOltpQM1','10.23.110.93','4361')17create_qcf(mq,'FCBSITOltpQM2','jms/FCBSITOltpQM2','FCBSITOltpQM2','10.23.110.93','4362')18create_qcf(mq,'FCBSITReportQM1','jms/FCBSITReportQM1','FCBSITReportQM1','10.23.110.93','4381')19create_qcf(mq,'FCBSITReportQM2','jms/FCBSITReportQM2','FCBSITReportQM2','10.23.110.93','4382')20def create_queue(provider,name,jndiName,qm,qn,host,port):21 global AdminConfig22 nameAttr = ['name', name]23 jndiAttr = ['jndiName', jndiName]24 qnAttr = ['baseQueueName', qn]25 qmAttr = ['baseQueueManagerName',qm]26 hostAttr = ['queueManagerHost',host]27 portAttr = ['queueManagerPort',port]28 attrs = [nameAttr, jndiAttr, qnAttr, qmAttr, hostAttr, portAttr]29 queue = AdminConfig.create('MQQueue', provider, attrs)30print "--- create queue"31create_queue(mq,'FCBSITBatchRequestQ1','jms/FCBSITBatchRequestQ1','FCBSITBatchQM1','FCBSITBatchRequestQ','10.23.110.93',4364)32create_queue(mq,'FCBSITBatchRequestQ2','jms/FCBSITBatchRequestQ2','FCBSITBatchQM2','FCBSITBatchRequestQ','10.23.110.93',4368)33create_queue(mq,'FCBSITBatchShellQ1','jms/FCBSITBatchShellQ1','FCBSITBatchQM1','FCBSITBatchShellQ','10.23.110.93',4364) 34create_queue(mq,'FCBSITBatchShellQ2','jms/FCBSITBatchShellQ2','FCBSITBatchQM2','FCBSITBatchShellQ','10.23.110.93',4368) 35create_queue(mq,'FCBSITBatchResponseQ','jms/FCBSITBatchResponseQ','','FCBSITBatchResponseQ','10.23.110.93',0) # strange config, ask why 36create_queue(mq,'FCBSITOltpRequestQ1','jms/FCBSITOltpRequestQ1','FCBSITOltpQM1','FCBSITOltpRequestQ','10.23.110.93',4361)37create_queue(mq,'FCBSITOltpRequestQ2','jms/FCBSITOltpRequestQ2','FCBSITOltpQM2','FCBSITOltpRequestQ','10.23.110.93',4362)38create_queue(mq,'FCBSITOltpResponseQ','jms/FCBSITOltpResponseQ','','FCBSITOltpResponseQ','10.23.110.93',0)39create_queue(mq,'FCBSITReportRequestQ1','jms/FCBSITReportRequestQ1','FCBSITReportQM1','FCBSITReportRequestQ','10.23.110.93',4381)40create_queue(mq,'FCBSITReportRequestQ2','jms/FCBSITReportRequestQ2','FCBSITReportQM2','FCBSITReportRequestQ','10.23.110.93',4382)41create_queue(mq,'FCBSITReportResponseQ','jms/FCBSITReportResponseQ','','FCBSITReportResponseQ','10.23.110.93',0)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
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.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!