import gevent from pyxmpp2.jid import JID import time from utils.meta.singleton import Singleton from lib.xmpp import make_xmpp_relation from utils.service_control.finder import get_cur_ip from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME # xmpp username user_name1 = "xmpp_message_test1" + "_%s" % get_cur_ip() user_name2 = "xmpp_message_test2" + "_%s" % get_cur_ip() user_name3 = "xmpp_message_test3" + "_%s" % get_cur_ip() [(user_jid1, user_jid_pass1), (user_jid2, user_jid_pass2), (user_jid3, user_jid_pass3)] \ = make_xmpp_relation([user_name1, user_name2, user_name3], add_roster=True) # xmpp client xmpp_client = XMPPClient() xmpp_client.init(JID(user_jid1), user_jid_pass1) xmpp_client.start() # mqtt client mqtt_client2 = MQTTClient() mqtt_client2.init(MQTT_IP, MQTT_PORT) mqtt_client2.start() mqtt_client3 = MQTTClient() mqtt_client3.init(MQTT_IP, MQTT_PORT) mqtt_client3.start()
Created on 2015-7-20 @author: Jay """ from lib.common import * from interfaces.bridge.xmpp_rpc import bridge_message from lib.user import LoginGetTokenUser from lib.service import * from lib.xmpp import make_xmpp_relation # xmpp username bridge_xmpp_test1 = "bridge_xmpp_test1" bridge_xmpp_test2 = "bridge_xmpp_test2" [(bridge_xmpp_test_jid1, bridge_xmpp_test_pass1), (bridge_xmpp_test_jid2, bridge_xmpp_test_pass2)] \ = make_xmpp_relation([bridge_xmpp_test1, bridge_xmpp_test2], add_roster=True) # start xmpp client BrgXmppClt1 = XMPPClient() BrgXmppClt1.init(JID(bridge_xmpp_test_jid1), bridge_xmpp_test_pass1) BrgXmppClt1.start() time.sleep(SYNC_WAIT_TIME) BrgXmppClt2 = XMPPClient() BrgXmppClt2.init(JID(bridge_xmpp_test_jid2), bridge_xmpp_test_pass2) BrgXmppClt2.start() time.sleep(SYNC_WAIT_TIME) _RECV_STANZA2 = {} @xmpp_handler(BrgXmppClt2, xmpp.S_C_RECV_BRIDGE_MESSGAE) def receive_bridge_message2(xmpp_client, from_jid, body):
@author: Jay """ from lib.common import * from lib.service import * from utils.network.mqtt import MQTTClient import time from interfaces.mxadap import mqtt from utils.wapper.stackless import gevent_adaptor from lib.xmpp import make_xmpp_relation from utils.service_control.finder import get_cur_ip from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME login_test_user_name1 = "xmpp_roster_expire_test1" + "_%s" % get_cur_ip() [(login_test_jid1, login_test_password1)] \ = make_xmpp_relation([login_test_user_name1]) xmpp_logout_result = None class XmppExpireAdapter(object): """ LOGIN <==> LOGOUT """ def __init__(self): self.is_stop = False # mqtt client self.mqtt_client = MQTTClient() self.mqtt_client.init(MQTT_IP, MQTT_PORT) self.mqtt_client.start()
from lib.service import * from utils.network.mqtt import MQTTClient from interfaces.mxadap import mqtt from utils.wapper.stackless import gevent_adaptor from utils.meta.singleton import Singleton from utils.service_control.finder import get_cur_ip from lib.xmpp import make_xmpp_relation from utest_mxadap.utest_smoke import MXADAP_WAIT_BASE_TIME roster_test_user_name1 = "xmpp_roster_add_test1" + "_%s" % get_cur_ip() roster_test_password1 = "xmpp_roster_add_test1" + "_%s" % get_cur_ip() roster_test_user_name2 = "xmpp_roster_add_test2" + "_%s" % get_cur_ip() roster_test_password2 = "xmpp_roster_add_test2" + "_%s" % get_cur_ip() [(roster_test_jid1, roster_test_password1), (roster_test_jid2, roster_test_password2)] \ = make_xmpp_relation([roster_test_user_name1, roster_test_user_name2], del_roster=True) xmpp_login_result = None xmpp_roster_add_result = None xmpp_roster_del_result = None xmpp_roster_present_notify_dic = {} presence_type = [u"subscribe", u"subscribed", u"unsubscribe", u"unsubscribed", u"available", u"unavailable"] class MqttRosterAdapter(object): """ roster_test_jid2 add roster_test_jid1 to the roster """ __metaclass__ = Singleton def __init__(self):
Created on 2015-5-7 @author: Jay """ from lib.common import * from interfaces.bridge.tcp_rpc import bridge_message from lib.user import LoginGetTokenUser from lib.service import * from lib.xmpp import make_xmpp_relation # xmpp username bridge_rpc_test1 = "bridge_rpc_test1" bridge_rpc_test2 = "bridge_rpc_test2" [(bridge_rpc_test1, bridge_rpc_test1), (bridge_rpc_test_jid2, bridge_rpc_test_pass2)] = make_xmpp_relation( [bridge_rpc_test1, bridge_rpc_test2], add_roster=True ) token, user_info1 = LoginGetTokenUser(RgstHttpRpc, bridge_rpc_test1, bridge_rpc_test1) _, user_info2 = LoginGetTokenUser(RgstHttpRpc, bridge_rpc_test2, bridge_rpc_test2) # start xmpp client BrgXmppClt1 = XMPPClient() BrgXmppClt1.init(JID(user_info1["jid"]), bridge_rpc_test1) BrgXmppClt1.start() time.sleep(SYNC_WAIT_TIME) BrgXmppClt2 = XMPPClient() BrgXmppClt2.init(JID(user_info2["jid"]), bridge_rpc_test2) BrgXmppClt2.start() time.sleep(SYNC_WAIT_TIME)
# mqtt client mqtt_client1 = MQTTClient() mqtt_client1.init(MQTT_IP, MQTT_PORT) mqtt_client1.start() mqtt_client2 = MQTTClient() mqtt_client2.init(MQTT_IP, MQTT_PORT) mqtt_client2.start() # add jid and roster # xmpp client mqtt_name1 = "xmpp_presence_test1" + "_%s" % get_cur_ip() mqtt_name2 = "xmpp_presence_test2" + "_%s" % get_cur_ip() [(mqtt_jid1, mqtt_jid_pass1), (mqtt_jid2, mqtt_jid_pass2)] = make_xmpp_relation( [mqtt_name1, mqtt_name2], add_roster=True ) # should result xmpp_login_result = None xmpp_roster_result = None xmpp_roster_ls = None mxid1 = None mxid2 = None xmpp_roster_present_notify1 = None xmpp_roster_present_notify2 = None xmpp_logout_result1 = None xmpp_logout_result2 = None xmpp_logout_has_req = False