Save API calls for that particular tests. for debugging purpose.#9
Save API calls for that particular tests. for debugging purpose.#9Sidartha-CT wants to merge 2 commits into
Conversation
|
@codex , review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 781b8f9ad2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # forever across runs and generate_report() would copy the entire history | ||
| # (including stale pre-fix entries) into every report folder | ||
| try: | ||
| open(self.api_log_filename, 'w').close() |
There was a problem hiding this comment.
Stop truncating API logs per band
When --save_api is enabled, every LFCliBase/Realm construction truncates the log. lf_webpage.py constructs a new HttpDownload/Realm inside its for bands in args.bands loop but copies http.local_realm.api_log_filename into the report only once after the loop, so the default multi-band run erases earlier band entries when later bands initialize and the report only contains the last band's calls. Reset the file once per test run or append across band objects.
Useful? React with 👍 / 👎.
| """ | ||
| if not self.save_api: | ||
| return | ||
| status = "OK" if error is None else "ERROR" |
There was a problem hiding this comment.
Stop marking swallowed request failures as OK
LFRequest.json_post()/get() catch HTTPError/URLError and return None, so the callers commonly reach _log_api_call with both error and response_code as None for a failed LANforge request. This line then records [OK], making --save_api logs say failed setup/start/cleanup calls succeeded; treat a missing response as an error or propagate LFRequest's error state before writing the status.
Useful? React with 👍 / 👎.
| self.windows_eids = [] | ||
| self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) | ||
| self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, | ||
| _save_api=_save_api, _api_log_file_name=_api_log_file_name) |
There was a problem hiding this comment.
Propagate API logging to child profiles
With --save_api, this only enables logging on self.local_realm; new_http_profile() immediately creates an HTTPProfile whose own save_api remains the default False. HTTPProfile.start_cx(), stop_cx(), and cleanup() call self.json_post(), so the run/stop/cleanup APIs are omitted from the saved log even though the option advertises saving json_* calls for the test. Propagate the flag/log path to child profiles or route these calls through the enabled realm.
Useful? React with 👍 / 👎.
| # Copy the api log file (json_get/post/put/delete calls) into the report folder, if enabled | ||
| if getattr(self.local_realm, 'save_api', False): | ||
| try: | ||
| shutil.copy(self.local_realm.api_log_filename, report_path_date_time) |
There was a problem hiding this comment.
Copy the API log after cleanup finishes
This copies the log into the report while generate_report() is running, but main() calls http.postcleanup() only after generate_report() returns. Any cleanup requests appended after this copy are missing from the report artifact, which is exactly when debugging stale stations/endpoints usually needs the final API calls; move the copy to after post-cleanup or copy it again at the end.
Useful? React with 👍 / 👎.
| with open(self.api_log_filename, 'a') as api_log: | ||
| api_log.write("%s %s %s [%s]\n" % (datetime.datetime.now().isoformat(), method, url, status)) | ||
| if data is not None: | ||
| api_log.write(" payload: %s\n" % json.dumps(data, default=str)) |
There was a problem hiding this comment.
Redact secrets before writing payloads
When save_api is enabled for code paths that send credentials, this writes raw request payloads to a log file that lf_webpage.py can copy into report artifacts. Existing LANforge payloads use fields such as passwd, password, and key for Wi-Fi/DUT credentials, so the report can leak secrets to anyone who receives it; redact common secret fields or make payload logging explicitly opt-in.
Useful? React with 👍 / 👎.
Signed-off-by: Sidartha-CT <neelapu.sidartha@candelatech.com>
781b8f9 to
a6a1620
Compare
Signed-off-by: Sidartha-CT <neelapu.sidartha@candelatech.com>
No description provided.