How to use _init_service_metric_counter method in localstack

Best Python code snippet using localstack_python

metric_aggregator.py

Source:metric_aggregator.py Github

copy

Full Screen

...117 output += f"<details><summary>{operation_tested/operation_counter*100:.2f}% test coverage</summary>\n\n{tmp}\n</details>\n"118 with open(file_name, "a") as fd:119 fd.write(f"{output}\n")120 output = ""121def _init_service_metric_counter() -> Dict:122 metric_recorder = {}123 from localstack.aws.spec import load_service124 for s, provider in SERVICE_PLUGINS.api_provider_specs.items():125 try:126 service = load_service(s)127 ops = {}128 service_attributes = {"pro": "pro" in provider, "community": "default" in provider}129 ops["service_attributes"] = service_attributes130 for op in service.operation_names:131 attributes = {}132 attributes["invoked"] = 0133 attributes["aws_validated"] = False134 attributes["snapshot"] = False135 if hasattr(service.operation_model(op).input_shape, "members"):136 params = {}137 for n in service.operation_model(op).input_shape.members:138 params[n] = 0139 attributes["parameters"] = params140 if hasattr(service.operation_model(op), "error_shapes"):141 exceptions = {}142 for e in service.operation_model(op).error_shapes:143 exceptions[e.name] = 0144 attributes["errors"] = exceptions145 ops[op] = attributes146 metric_recorder[s] = ops147 except Exception:148 LOG.debug(f"cannot load service '{s}'")149 return metric_recorder150def print_usage():151 print("missing argument: directory")152 print("usage: python metric_aggregator.py <dir-to-raw-csv-metric> [amd64|arch64]")153def write_json(file_name: str, metric_dict: dict):154 with open(file_name, "w") as fd:155 fd.write(json.dumps(metric_dict, indent=2, sort_keys=True))156def _print_diff(metric_recorder_internal, metric_recorder_external):157 for key, val in metric_recorder_internal.items():158 for subkey, val in val.items():159 if isinstance(val, dict) and val.get("invoked"):160 if val["invoked"] > 0 and not metric_recorder_external[key][subkey]["invoked"]:161 print(f"found invocation mismatch: {key}.{subkey}")162def append_row_to_raw_collection(collection_raw_csv_file_name, row, arch):163 with open(collection_raw_csv_file_name, "a") as fd:164 writer = csv.writer(fd)165 row.append(arch)166 writer.writerow(row)167def aggregate_recorded_raw_data(168 base_dir: str, collection_raw_csv: Optional[str] = None, collect_for_arch: Optional[str] = ""169) -> dict:170 pathlist = Path(base_dir).rglob("metric-report-raw-data-*.csv")171 recorded = _init_service_metric_counter()172 for path in pathlist:173 print(f"checking {str(path)}")174 with open(path, "r") as csv_obj:175 csv_dict_reader = csv.reader(csv_obj)176 # skip the header177 next(csv_dict_reader)178 for row in csv_dict_reader:179 if collection_raw_csv:180 arch = ""181 if "arm64" in str(path):182 arch = "arm64"183 elif "amd64" in str(path):184 arch = "amd64"185 # only aggregate all if we did not set a specific target to collect...

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