我是靠谱客的博主 勤恳小丸子,最近开发中收集的这篇文章主要介绍Python Server端性能测试 - Mock环境搭建,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1, create a stored procedure in mysql;

    1, copy sp.sql to /root/ on dev01o

    2, log on mysql

    3, source  /root/sp.sql

2,    delete devices where id>24000;

3,  delete users where id >6000;


4,  execute sql: call sp_deleteDevices;

5, export device data:

    1: create an view  in mysql
create view view_devices as select `d`.`Id` AS `Id`,`d`.`Udid` AS `Udid`,`d`.`SerialNumber` AS `SerialNumber`,`d`.`MacAddress` AS `MacAddress`,`d`.`Imei` AS `Imei`,`d`.`AssetNumber` AS `AssetNumber`,`d`.`DeviceFriendlyName` AS `DeviceFriendlyName`,`g`.`Name` AS `LocationGroupName`,`l`.`DisplayName` AS `GroupLocation`,`u`.`UserName` AS `UserName`,`u`.`Email` AS `Email`,`d`.`Ownership` AS `Ownership`,`p`.`Platform` AS `Platform`,`m`.`ModelName` AS `ModelName`,`d`.`OperatingSystem` AS `OperatingSystem`,`d`.`PhoneNumber` AS `PhoneNumber`,`d`.`LastSeen` AS `LastSeen`,`d`.`EnrollmentStatus` AS `EnrollmentStatus`,`d`.`ComplianceStatus` AS `ComplianceStatus`,`d`.`CompromisedStatus` AS `CompromisedStatus`,`d`.`LastEnrolledOn` AS `LastEnrolledOn`,`d`.`LastComplianceCheckOn` AS `LastComplianceCheckOn`,`d`.`LastCompromisedCheckOn` AS `LastCompromisedCheckOn`,`d`.`OverallCompliantStatus` AS `OverallCompliantStatus` from ((((((`users` `u` join `groups` `g` on((`u`.`GroupId` = `g`.`Id`))) left join `location` `l` on((`g`.`Id` = `l`.`GroupId`))) join `devices` `d` on((`d`.`User` = `u`.`Id`))) left join `compliance` `c` on((`c`.`DeviceId` = `d`.`Id`))) left join `platform` `p` on((`d`.`Platform` = `p`.`Id`))) left join `managedappsupportedmodel` `m` on((`m`.`ModeId` = `d`.`Model`))) order by `d`.`Id` ;
 

    2, export this view data.

    select * from view_devices into outfile 'devices.txt';

After add group, need add corresponding location into location table:

INSERT into location(GroupId,InternalName,DisplayName)

select id, 'USA Iname','USA Dname' from groups where id>27;


-----------------------------------------------------

sp.sql

-- ----------------------------

-- Procedure structure for `sp_deleteDevices`

-- ----------------------------

DROP PROCEDURE IF EXISTS `sp_deleteDevices`;

DELIMITER ;;

CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `sp_deleteDevices`()

BEGIN



DECLARE done INT DEFAULT 0;

DECLARE userid BIGINT;

DECLARE cur CURSOR FOR SELECT Id FROM users;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

create table temp(id BIGINT);

OPEN cur;

fetch cur into userid;

WHILE done=0 DO

insert into temp(id)

select id from devices where User=userid limit 2,2;

FETCH cur INTO userid;

 END WHILE;

  CLOSE cur;

DELETE from devices where id in (select id from temp);

drop table temp;

END

;;

DELIMITER ;

--------------------------------------------------------------------------------------

-- ----------------------------

-- Procedure structure for `sp_updateDevices`

-- ----------------------------

DROP PROCEDURE IF EXISTS `sp_updateDevices`;

DELIMITER ;;

CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `sp_updateDevices`()

BEGIN



DECLARE done INT DEFAULT 0;

DECLARE userid BIGINT;

DECLARE cur CURSOR FOR SELECT Id FROM users;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

create table temp(id BIGINT);

OPEN cur;

fetch cur into userid;

WHILE done=0 DO

insert into temp(id)

select id from devices where User=userid limit 1,1;

FETCH cur INTO userid;

 END WHILE;

  CLOSE cur;

update devices set Platform=5, Model=5, OperatingSystem='4.1.2', DeviceFriendlyName='Android phone' where id in (select id from temp);

drop table temp;

END

;;

DELIMITER ;


最后

以上就是勤恳小丸子为你收集整理的Python Server端性能测试 - Mock环境搭建的全部内容,希望文章能够帮你解决Python Server端性能测试 - Mock环境搭建所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部