package com.okayqa.composer.performance.resource1_4
import com.alibaba.fastjson.JSON
import com.alibaba.fastjson.JSONObject
import com.funtester.base.bean.AbstractBean
import com.funtester.base.constaint.ThreadLimitTimesCount
import com.funtester.frame.execute.Concurrent
import com.funtester.httpclient.ClientManage
import com.funtester.utils.ArgsUtil
import com.okayqa.composer.base.OkayBase
import com.okayqa.composer.function.Mirro
import com.okayqa.composer.function.OKClass
class Login_collect_uncollect extends OkayBase {
public static void main(String[] args) {
ClientManage.init(10, 5, 0, "", 0)
def util = new ArgsUtil(args)
def thread = util.getIntOrdefault(0, 30)
def times = util.getIntOrdefault(1, 40)
def tasks = []
thread.times {
tasks << new FunTester(it, times)
}
new Concurrent(tasks, "资源库1.4登录>查询>收藏>取消收藏链路压测").start()
allOver()
}
private static class FunTester extends ThreadLimitTimesCount<Integer> {
OkayBase base
def mirro
def clazz
FunTester(Integer integer, int times) {
super(integer, times, null)
}
@Override
void before() {
super.before()
base = getBase(t)
mirro = new Mirro(base)
clazz = new OKClass(base)
}
@Override
protected void doing() throws Exception {
def klist = mirro.getKList()
def karray = klist.getJSONArray("data")
K ks
karray.each {
JSONObject parse = JSON.parse(JSON.toJSONString(it))
if (ks == null) {
def level = parse.getIntValue("node_level")
def type = parse.getIntValue("ktype")
def id = parse.getIntValue("id")
ks = new K(id, type, level)
}
}
JSONObject response = clazz.recommend(ks.id, ks.type, ks.level)
def minis = []
int i = 0
response.getJSONArray("data").each {
if (i++ < 2) {
JSONObject parse = JSON.parse(JSON.toJSONString(it))
int value = parse.getIntValue("minicourse_id")
minis << value
}
}
clazz.unCollect(random(minis))
mirro.getMiniCourseListV3(ks.id, ks.type, 0, ks.level)
}
}
private static class K extends AbstractBean {
int id
int type
int level
K(int id, int type, int level) {
this.id = id
this.type = type
this.level = level
}
}
}
评论