Skip to content

Save API calls for that particular tests. for debugging purpose.#9

Open
Sidartha-CT wants to merge 2 commits into
masterfrom
multi_traffic_feat
Open

Save API calls for that particular tests. for debugging purpose.#9
Sidartha-CT wants to merge 2 commits into
masterfrom
multi_traffic_feat

Conversation

@Sidartha-CT

Copy link
Copy Markdown
Owner

No description provided.

@Sidartha-CT

Copy link
Copy Markdown
Owner Author

@codex , review.

@Sidartha-CT

Copy link
Copy Markdown
Owner Author

lf_api_calls.log

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread py-json/LANforge/lfcli_base.py Outdated
"""
if not self.save_api:
return
status = "OK" if error is None else "ERROR"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread py-scripts/lf_webpage.py
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread py-scripts/lf_webpage.py
# 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
Signed-off-by: Sidartha-CT <neelapu.sidartha@candelatech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant