How to use update_consumer method in tempest

Best Python code snippet using tempest_python

routing.py

Source:routing.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import logging3import os4from importlib import import_module5from channels.routing import route6from django.conf import settings7from cloud_client.utils.update import ws_consumer as update_consumer8logger = logging.getLogger(__name__)9channel_routing = [10 route("websocket.connect", update_consumer.ws_add, path=r'^/update/websocket/state/$'),11 route("websocket.receive", update_consumer.ws_message, path=r'^/update/websocket/state/$'),12 route("websocket.disconnect", update_consumer.ws_disconnect, path=r'^/update/websocket/state/$')13]14if settings.PLATFORM_TYPE == "AD" or settings.PLATFORM_TYPE == "ALL":15 from event_attack_defense.cms.handler.checker import checker16 from event_attack_defense.cms.handler.control import control17 from event_attack_defense.cms.handler.deploy import flag, task18 from event_attack_defense.cms.handler.statistic import statistic19 from event_attack_defense.util import consumer20 from practice.utils.practice_task import ws_consumer as practice_consumer21 channel_routing.extend([22 route('push-flag', flag.push_flag_message),23 route('control', control.control_message),24 route('check', checker.check_round_message),25 route('statistic', statistic.statistic_message),26 route('task_deploy', task.deploy_team_task_message),27 route("websocket.connect", consumer.ws_add, path=r"^/ad/websocket/(?P<event_hash>[0-9a-z\-\.]+)/$"),28 route("websocket.receive", consumer.ws_message, path=r"^/ad/websocket/(?P<event_hash>[0-9a-z\-\.]+)/$"),29 route("websocket.disconnect", consumer.ws_disconnect, path=r"^/ad/websocket/(?P<event_hash>[0-9a-z\-\.]+)/$"),30 route("websocket.connect", consumer.public_ws_add, path=r"^/ad/public/(?P<event_hash>[0-9a-z\-\.]+)/$"),31 route("websocket.receive", consumer.public_ws_message, path=r"^/ad/public/(?P<event_hash>[0-9a-z\-\.]+)/$"),32 route("websocket.disconnect", consumer.public_ws_disconnect,33 path=r"^/ad/public/(?P<event_hash>[0-9a-z\-\.]+)/$"),34 route("websocket.connect", practice_consumer.ws_add, path=r'^/practice/websocket/task/(?P<task_hash>[0-9a-z\-\.]+)/$'),35 route("websocket.receive", practice_consumer.ws_message, path=r'^/practice/websocket/task/(?P<task_hash>[0-9a-z\-\.]+)/$'),36 route("websocket.disconnect", practice_consumer.ws_disconnect, path=r'^/practice/websocket/task/(?P<task_hash>[0-9a-z\-\.]+)/$'),37 ])38if settings.PLATFORM_TYPE == "OJ" or settings.PLATFORM_TYPE == 'ALL':39 from course.utils.lesson import ws_consumer as lesson_consumer40 channel_routing.extend([41 route("websocket.connect", lesson_consumer.ws_add,42 path=r"^/course/websocket/lesson/(?P<lesson_hash>[0-9a-z\-\.]+)/$"),43 route("websocket.receive", lesson_consumer.ws_message,44 path=r"^/course/websocket/lesson/(?P<lesson_hash>[0-9a-z\-\.]+)/$"),45 route("websocket.disconnect", lesson_consumer.ws_disconnect,46 path=r"^/course/websocket/lesson/(?P<lesson_hash>[0-9a-z\-\.]+)/$"),47 ])48# 为每一个模块添加路由49for app in settings.XCTF_APPS + settings.BASE_APPS:50 full_routing_path = os.path.join(settings.BASE_DIR, app, 'routing.py')51 if os.path.exists(full_routing_path):52 routing_path = '%s.%s' % (app, 'routing')53 try:54 _app_routing = import_module(routing_path)55 app_routing = _app_routing.routing56 if not app_routing:57 continue58 channel_routing.extend(app_routing)59 except Exception, e:60 logger.info("load routing error error[%s]", str(e))...

Full Screen

Full Screen

server.py

Source:server.py Github

copy

Full Screen

1'''2Created on Jan 11, 20123@author: boatkrap4'''5from ..messaging import connection6from nokkhum import config7from nokkhum.controller.compute_node import update8from nokkhum.controller import schedule9import netifaces10import logging11logger = logging.getLogger(__name__)12class ControllerServer:13 def __init__(self, configuration):14 self._running = False15 self.configuration = configuration16 self.update_status = update.UpdateStatus()17 self.reconnect_message_connection()18 self.timer = schedule.timer.Timer()19 def reconnect_message_connection(self):20 from nokkhum.messaging import connection21 if connection.Connection.get_instance() is None:22 connection.Connection(self.configuration.settings.get('amq.url'))23 else:24 connection.Connection.get_instance().reconnect()25 ip = "127.0.0.1"26 try:27 ip = netifaces.ifaddresses(config.Configurator.settings.get(28 'nokkhum.controller.interface')).setdefault(netifaces.AF_INET)[0]['addr']29 except Exception as e:30 logger.exception(e)31 ip = netifaces.ifaddresses('lo').setdefault(32 netifaces.AF_INET)[0]['addr']33 self.rpc_client = connection.Connection.get_instance()\34 .get_rpc_factory().get_default_rpc_client(ip)35 self.update_consumer = connection.Connection.get_instance()\36 .consumer_factory.get_consumer("nokkhum_compute.update_status")37 self.update_status.set_consumer(self.update_consumer)38 def start(self):39 self._running = True40 self.update_status.start()41 self.timer.start()42 while self._running:43 logger.debug("drain_event")44 try:45 connection.Connection.get_instance().drain_events()46 except KeyboardInterrupt as e:47 self.stop()48 raise e49 except Exception as e:50 logger.exception(e)51 logger.debug("reconnect message server")52 # connection.Connection.get_instance().reconnect()53 self.reconnect_message_connection()54 def stop(self):55 self._running = False56 self.update_status.stop()57 self.timer.stop()58 self.update_status.join()59 self.timer.join()60 try:61 connection.Connection.get_instance().release()62 except:...

Full Screen

Full Screen

consumer_service.py

Source:consumer_service.py Github

copy

Full Screen

...6 return consumers7 def add_consumer(self, consumer):8 consumer = self.repo.add_consumer(consumer)9 return consumer10 def update_consumer(self, consumer):11 consumer = self.repo.update_consumer(consumer)12 return consumer13 def delete_consumer(self, consumer):14 success = self.repo.update_consumer(consumer)15 return success16 def upload_image(self, image):17 image_id = self.repo.upload_image(image)18 return image_id19 def update_image(self, image):20 self.repo.update_image(image)21 22 def get_image(self, image_id):23 image = self.repo.get_image(image_id)24 return image25 def check_existence(self, phone_number):26 success = self.repo.check_existence(phone_number)27 return success28 def login_consumer(self, phone_number):...

Full Screen

Full Screen

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 tempest 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