How to use get_level_str method in yandex-tank

Best Python code snippet using yandex-tank

cumulative_criterions.py

Source:cumulative_criterions.py Github

copy

Full Screen

...127 return True128 return False129 def get_rc(self):130 return 26131 def get_level_str(self):132 ''' format level str '''133 if self.is_relative:134 level_str = str(self.level) + "%"135 else:136 level_str = self.level137 return level_str138 def explain(self):139 if self.is_relative:140 items = (141 self.codes_mask, self.get_level_str(), self.seconds_limit,142 self.cause_second[0]["ts"])143 return (144 "%s codes count higher "145 "than %s for %ss, ended at: %s" % items)146 items = (147 self.codes_mask, self.get_level_str(), self.seconds_limit,148 self.cause_second[0]["ts"])149 return "%s codes count higher than %s for %ss, since %s" % items150 def widget_explain(self):151 if self.is_relative:152 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)153 return ("HTTP %s>%s for %ss" % items, sum(self.data))154 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)155 return ("HTTP %s>%s for %ss" % items, 1.0)156class TotalNetCodesCriterion(AbstractCriterion):157 ''' Cummulative Net Criterion '''158 @staticmethod159 def get_type_string():160 return 'total_net'161 def __init__(self, autostop, param_str):162 AbstractCriterion.__init__(self)163 self.seconds_count = 0164 self.codes_mask = param_str.split(',')[0].lower()165 self.codes_regex = re.compile(self.codes_mask.replace("x", '.'))166 self.autostop = autostop167 self.data = deque()168 self.second_window = deque()169 level_str = param_str.split(',')[1].strip()170 if level_str[-1:] == '%':171 self.level = float(level_str[:-1])172 self.is_relative = True173 else:174 self.level = int(level_str)175 self.is_relative = False176 self.seconds_limit = expand_to_seconds(param_str.split(',')[2])177 def notify(self, data, stat):178 codes = data["overall"]["net_code"]["count"].copy()179 if '0' in codes.keys():180 codes.pop('0')181 matched_responses = self.count_matched_codes(self.codes_regex, codes)182 if self.is_relative:183 if data["overall"]["interval_real"]["len"]:184 matched_responses = float(matched_responses) / data["overall"][185 "interval_real"]["len"] * 100186 logger.debug(187 "Net codes matching mask %s: %s%%/%s", self.codes_mask,188 round(matched_responses, 2), self.get_level_str())189 else:190 matched_responses = 1191 else:192 logger.debug(193 "Net codes matching mask %s: %s/%s", self.codes_mask,194 matched_responses, self.get_level_str())195 self.data.append(matched_responses)196 self.second_window.append((data, stat))197 if len(self.data) > self.seconds_limit:198 self.data.popleft()199 self.second_window.popleft()200 queue_len = 1201 if self.is_relative:202 queue_len = len(self.data)203 if (sum(self.data) / queue_len) >= self.level\204 and len(self.data) >= self.seconds_limit: # yapf:disable205 self.cause_second = self.second_window[0]206 logger.debug(self.explain())207 return True208 return False209 def get_rc(self):210 return 27211 def get_level_str(self):212 ''' format level str '''213 if self.is_relative:214 level_str = str(self.level) + "%"215 else:216 level_str = str(self.level)217 return level_str218 def explain(self):219 if self.is_relative:220 items = (221 self.codes_mask, self.get_level_str(), self.seconds_limit,222 self.cause_second[0]["ts"])223 return (224 "%s net codes count higher "225 "than %s for %ss, since %s" % items)226 items = (227 self.codes_mask, self.get_level_str(), self.seconds_limit,228 self.cause_second[0]["ts"])229 return "%s net codes count higher than %s for %ss, since %s" % items230 def widget_explain(self):231 if self.is_relative:232 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)233 return ("Net %s>%s for %ss" % items, self.level)234 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)235 return ("Net %s>%s for %ss" % items, self.level)236class TotalNegativeHTTPCodesCriterion(AbstractCriterion):237 ''' Reversed HTTP Criterion '''238 @staticmethod239 def get_type_string():240 return 'negative_http'241 def __init__(self, autostop, param_str):242 AbstractCriterion.__init__(self)243 self.seconds_count = 0244 self.codes_mask = param_str.split(',')[0].lower()245 self.codes_regex = re.compile(self.codes_mask.replace("x", '.'))246 self.autostop = autostop247 self.data = deque()248 self.second_window = deque()249 level_str = param_str.split(',')[1].strip()250 if level_str[-1:] == '%':251 self.level = float(level_str[:-1])252 self.is_relative = True253 else:254 self.level = int(level_str)255 self.is_relative = False256 self.seconds_limit = expand_to_seconds(param_str.split(',')[2])257 def notify(self, data, stat):258 matched_responses = self.count_matched_codes(259 self.codes_regex, data["overall"]["proto_code"]["count"])260 if self.is_relative:261 if data["overall"]["interval_real"]["len"]:262 matched_responses = float(matched_responses) / data["overall"][263 "interval_real"]["len"] * 100264 matched_responses = 100 - matched_responses265 else:266 matched_responses = 1267 logger.debug(268 "HTTP codes matching mask not %s: %s/%s", self.codes_mask,269 round(matched_responses, 1), self.level)270 else:271 matched_responses = (272 data["overall"]["interval_real"]["len"] - matched_responses)273 logger.debug(274 "HTTP codes matching mask not %s: %s/%s", self.codes_mask,275 matched_responses, self.level)276 self.data.append(matched_responses)277 self.second_window.append((data, stat))278 if len(self.data) > self.seconds_limit:279 self.data.popleft()280 self.second_window.popleft()281 queue_len = 1282 if self.is_relative:283 queue_len = len(self.data)284 if (sum(self.data) / queue_len) >= self.level\285 and len(self.data) >= self.seconds_limit: # yapf:disable286 self.cause_second = self.second_window[0]287 logger.debug(self.explain())288 return True289 return False290 def get_rc(self):291 return 28292 def get_level_str(self):293 ''' format level str'''294 if self.is_relative:295 level_str = str(self.level) + "%"296 else:297 level_str = self.level298 return level_str299 def explain(self):300 if self.is_relative:301 items = (302 self.codes_mask, self.get_level_str(), self.seconds_limit,303 self.cause_second[0]["ts"])304 return (305 "Not %s codes count higher "306 "than %s for %ss, since %s" % items)307 items = (308 self.codes_mask, self.get_level_str(), self.seconds_limit,309 self.cause_second[0]["ts"])310 return "Not %s codes count higher than %s for %ss, since %s" % items311 def widget_explain(self):312 if self.is_relative:313 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)314 return ("HTTP not %s>%s for %ss" % items, sum(self.data))315 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)316 return ("HTTP not %s>%s for %ss" % items, 1.0)317class TotalNegativeNetCodesCriterion(AbstractCriterion):318 ''' Reversed NET Criterion '''319 @staticmethod320 def get_type_string():321 return 'negative_net'322 def __init__(self, autostop, param_str):323 AbstractCriterion.__init__(self)324 self.seconds_count = 0325 self.codes_mask = param_str.split(',')[0].lower()326 self.codes_regex = re.compile(self.codes_mask.replace("x", '.'))327 self.autostop = autostop328 self.data = deque()329 self.second_window = deque()330 level_str = param_str.split(',')[1].strip()331 if level_str[-1:] == '%':332 self.level = float(level_str[:-1])333 self.is_relative = True334 else:335 self.level = int(level_str)336 self.is_relative = False337 self.seconds_limit = expand_to_seconds(param_str.split(',')[2])338 def notify(self, data, stat):339 codes = data["overall"]["net_code"]["count"].copy()340 # if '0' in codes.keys():341 # codes.pop('0')342 matched_responses = self.count_matched_codes(self.codes_regex, codes)343 if self.is_relative:344 if data["overall"]["interval_real"]["len"]:345 matched_responses = float(matched_responses) / data["overall"][346 "interval_real"]["len"] * 100347 matched_responses = 100 - matched_responses348 else:349 matched_responses = 1350 logger.debug(351 "Net codes matching mask not %s: %s/%s", self.codes_mask,352 round(matched_responses, 1), self.level)353 else:354 matched_responses = (355 data["overall"]["interval_real"]["len"] - matched_responses)356 logger.debug(357 "Net codes matching mask not %s: %s/%s", self.codes_mask,358 matched_responses, self.level)359 self.data.append(matched_responses)360 self.second_window.append((data, stat))361 if len(self.data) > self.seconds_limit:362 self.data.popleft()363 self.second_window.popleft()364 queue_len = 1365 if self.is_relative:366 queue_len = len(self.data)367 if (sum(self.data) / queue_len) >= self.level \368 and len(self.data) >= self.seconds_limit: # yapf:disable369 self.cause_second = self.second_window[0]370 logger.debug(self.explain())371 return True372 return False373 def get_rc(self):374 return 29375 def get_level_str(self):376 ''' format level str'''377 if self.is_relative:378 level_str = str(self.level) + "%"379 else:380 level_str = self.level381 return level_str382 def explain(self):383 if self.is_relative:384 items = (385 self.codes_mask, self.get_level_str(), self.seconds_limit,386 self.cause_second[0]["ts"])387 return (388 "Not %s codes count higher "389 "than %s for %ss, since %s" % items)390 items = (391 self.codes_mask, self.get_level_str(), self.seconds_limit,392 self.cause_second[0]["ts"])393 return "Not %s codes count higher than %s for %ss, since %s" % items394 def widget_explain(self):395 if self.is_relative:396 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)397 return ("Net not %s>%s for %ss" % items, sum(self.data))398 items = (self.codes_mask, self.get_level_str(), self.seconds_limit)399 return ("Net not %s>%s for %ss" % items, 1.0)400class TotalHTTPTrendCriterion(AbstractCriterion):401 ''' HTTP Trend Criterion '''402 @staticmethod403 def get_type_string():404 return 'http_trend'405 def __init__(self, autostop, param_str):406 AbstractCriterion.__init__(self)407 self.seconds_count = 0408 self.codes_mask = param_str.split(',')[0].lower()409 self.codes_regex = re.compile(self.codes_mask.replace("x", '.'))410 self.autostop = autostop411 self.tangents = deque()412 self.second_window = deque()...

Full Screen

Full Screen

criterions.py

Source:criterions.py Github

copy

Full Screen

...86 self.seconds_count = 087 return False88 def get_rc(self):89 return self.RC_HTTP90 def get_level_str(self):91 """ format level str """92 if self.is_relative:93 level_str = str(100 * self.level) + "%"94 else:95 level_str = self.level96 return level_str97 def explain(self):98 items = (99 self.codes_mask, self.get_level_str(), self.seconds_count,100 self.cause_second[0].get('ts'))101 return "%s codes count higher than %s for %ss, since %s" % items102 def widget_explain(self):103 items = (104 self.codes_mask, self.get_level_str(), self.seconds_count,105 self.seconds_limit)106 return "HTTP %s>%s for %s/%ss" % items, float(107 self.seconds_count) / self.seconds_limit108class NetCodesCriterion(AbstractCriterion):109 """ Net codes criterion """110 @staticmethod111 def get_type_string():112 return 'net'113 def __init__(self, autostop, param_str):114 AbstractCriterion.__init__(self)115 self.seconds_count = 0116 self.codes_mask = param_str.split(',')[0].lower()117 self.codes_regex = re.compile(self.codes_mask.replace("x", '.'))118 self.autostop = autostop119 level_str = param_str.split(',')[1].strip()120 if level_str[-1:] == '%':121 self.level = float(level_str[:-1]) / 100122 self.is_relative = True123 else:124 self.level = int(level_str)125 self.is_relative = False126 self.seconds_limit = expand_to_seconds(param_str.split(',')[2])127 def notify(self, data, stat):128 codes = copy.deepcopy(data["overall"]["net_code"]["count"])129 if '0' in codes.keys():130 codes.pop('0')131 matched_responses = self.count_matched_codes(self.codes_regex, codes)132 if self.is_relative:133 if data["overall"]["interval_real"]["len"]:134 matched_responses = float(matched_responses) / data["overall"][135 "interval_real"]["len"]136 else:137 matched_responses = 0138 logger.debug(139 "Net codes matching mask %s: %s/%s", self.codes_mask,140 matched_responses, self.level)141 if matched_responses >= self.level:142 if not self.seconds_count:143 self.cause_second = (data, stat)144 logger.debug(self.explain())145 self.seconds_count += 1146 self.autostop.add_counting(self)147 if self.seconds_count >= self.seconds_limit:148 return True149 else:150 self.seconds_count = 0151 return False152 def get_rc(self):153 return self.RC_NET154 def get_level_str(self):155 """ format level str """156 if self.is_relative:157 level_str = str(100 * self.level) + "%"158 else:159 level_str = self.level160 return level_str161 def explain(self):162 items = (163 self.codes_mask, self.get_level_str(), self.seconds_count,164 self.cause_second[0].get("ts"))165 return "%s net codes count higher than %s for %ss, since %s" % items166 def widget_explain(self):167 items = (168 self.codes_mask, self.get_level_str(), self.seconds_count,169 self.seconds_limit)170 return "Net %s>%s for %s/%ss" % items, float(171 self.seconds_count) / self.seconds_limit172class QuantileCriterion(AbstractCriterion):173 """ quantile criterion """174 @staticmethod175 def get_type_string():176 return 'quantile'177 def __init__(self, autostop, param_str):178 AbstractCriterion.__init__(self)179 self.seconds_count = 0180 self.quantile = float(param_str.split(',')[0])181 self.rt_limit = expand_to_milliseconds(param_str.split(',')[1])182 self.seconds_limit = expand_to_seconds(param_str.split(',')[2])...

Full Screen

Full Screen

Section.py

Source:Section.py Github

copy

Full Screen

1# File: Section2# Version 1.23# By Devin4# Last Modifed 30/8/215import enum6from src.Command import Command7class Level(enum.Enum):8 PART = -19 CHAPTER = 010 SECTION = 111 SUBSECTION = 212 SUBSUBSECTION = 313 PARAGRAPH = 414 SUBPARAGRAPH = 515def Get_Level_Str(level) -> str:16 levels = {17 Level.PART: "part",18 Level.CHAPTER: "chapter",19 Level.SECTION: "section",20 Level.SUBSECTION: "subsection",21 Level.SUBSUBSECTION: "subsubsection",22 level.PARAGRAPH: "paragraph",23 level.SUBPARAGRAPH: "subparagraph"24 }25 return levels.get(level)26class Section(Command):27 """Section """28 def __init__(self, _title: str, level=Level.SECTION):29 super().__init__(Get_Level_Str(level), mod=[], params=[_title])30 def __str__(self):...

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 yandex-tank 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