Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: remove backticks and use new logging #1954

Merged
merged 1 commit into from
May 7, 2024

Conversation

kosstennbl
Copy link
Collaborator

@kosstennbl kosstennbl commented Apr 8, 2024

Replace all backtick command execution with ShellCmd module.
Use Log instead of LOGGING module.
Fix edge-case issues caused by logging refactor.
Remove commented-out code.

Commit looks scary, but most of the code is changed with a couple of regexes, only small amount of collisions that were needed to be resolved manually is present.

Issues:

REF: #1495

No changes to documentation is needed.
Was tested for successful compilation.
Needs testing with github actions (some of the tests are hard to test on local environments)

spec/5g/core_spec.cr Outdated Show resolved Hide resolved
spec/5g/core_spec.cr Outdated Show resolved Hide resolved
spec/cnf_testsuite_all/cnf_testsuite_microservice_spec.cr Outdated Show resolved Hide resolved
spec/cnf_testsuite_all/cnf_testsuite_network_chaos_spec.cr Outdated Show resolved Hide resolved
src/tasks/utils/utils.cr Outdated Show resolved Hide resolved
@HashNuke
Copy link
Collaborator

HashNuke commented Apr 9, 2024

ShellCmd.run is more suitable for commands that either output stdout on success or stderr on failure. The stderr is output in the end after the stdout is logged.

  • The cnf-testsuite commands could be outputting both due to the nature of the integrations.
  • In the logs when looking into issues, it would help to see the output in the same order as the command's output rather than all the stdouts grouped first, followed by all the stderr outputs.

It would be better to use the same variable for collecting both stderr and stdout. That is a case for for a new function separate from ShellCmd.run.

@kosstennbl kosstennbl mentioned this pull request Apr 9, 2024
9 tasks
@kosstennbl
Copy link
Collaborator Author

ShellCmd.run is more suitable for commands that either output stdout on success or stderr on failure. The stderr is output in the end after the stdout is logged.

  • The cnf-testsuite commands could be outputting both due to the nature of the integrations.
  • In the logs when looking into issues, it would help to see the output in the same order as the command's output rather than all the stdouts grouped first, followed by all the stderr outputs.

It would be better to use the same variable for collecting both stderr and stdout. That is a case for for a new function separate from ShellCmd.run.

ShellCmd.run is more suitable for commands that either output stdout on success or stderr on failure. The stderr is output in the end after the stdout is logged.

  • The cnf-testsuite commands could be outputting both due to the nature of the integrations.
  • In the logs when looking into issues, it would help to see the output in the same order as the command's output rather than all the stdouts grouped first, followed by all the stderr outputs.

It would be better to use the same variable for collecting both stderr and stdout. That is a case for for a new function separate from ShellCmd.run.

As we have discussed earlier - agree, that sounds like a nice addition, but I'm not sure that it should be implemented in the scope of this PR.
As these changes for logging and backticks are quite wide and can bring confusion in some places - I'd rather prefer fixing (if needed) and merging this one, and then - creating new PR with addition of second command and using it where needed.

@kosstennbl kosstennbl force-pushed the backtick_spec_fix branch 5 times, most recently from b2f088f to cdcbaf3 Compare April 11, 2024 08:20
@kosstennbl kosstennbl changed the title spec: remove backticks and use new logging spec: refactor spec tests Apr 11, 2024
@kosstennbl kosstennbl changed the title spec: refactor spec tests spec: remove backticks and use new logging Apr 12, 2024
@kosstennbl kosstennbl force-pushed the backtick_spec_fix branch 2 times, most recently from 1ebb5ee to 2152086 Compare April 12, 2024 13:31
@kosstennbl kosstennbl force-pushed the backtick_spec_fix branch 5 times, most recently from 244b178 to 5961641 Compare April 16, 2024 12:07
@martin-mat martin-mat self-requested a review April 16, 2024 12:58
Copy link
Collaborator

@martin-mat martin-mat left a comment

Choose a reason for hiding this comment

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

lgtm

@kosstennbl
Copy link
Collaborator Author

@HashNuke @wavell @agentpoyo Please run tests

@HashNuke
Copy link
Collaborator

There are three tags that are failing in the build. I've run them a few times.
I've tried re-triggering a build here to confirm the failures - https://github.com/cnti-testcatalog/testsuite/actions/runs/8750289901

CleanShot 2024-04-19 at 16 57 47@2x

@kosstennbl kosstennbl force-pushed the backtick_spec_fix branch 2 times, most recently from 7c16f09 to ba63fc4 Compare April 19, 2024 12:19
@kosstennbl
Copy link
Collaborator Author

@HashNuke
Thanks for testing, observability and platform:observability are fixed.
Memory hog failure is probably happening due to #1973

Copy link
Collaborator

@HashNuke HashNuke left a comment

Choose a reason for hiding this comment

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

Posted about an error with screenshot.

LOGGING.info resp
$?.success?.should be_true
Log.info { resp }
result[:status].success?.should be_true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please look into this line. Below is the error from a build.

CleanShot 2024-04-21 at 11 05 57@2x

@HashNuke
Copy link
Collaborator

HashNuke commented Apr 21, 2024

@kosstennbl platform:observability spec still throws an error. Please check screenshot in review.
Also, this PR has conflicts now.

@kosstennbl kosstennbl force-pushed the backtick_spec_fix branch 2 times, most recently from af7b839 to 98d16cb Compare April 22, 2024 14:46
@kosstennbl
Copy link
Collaborator Author

@HashNuke Fixed conflicts, fixed platform:observability (it fails in my environment, but after fix - it looks like an environment issue rather than code issue)

@HashNuke
Copy link
Collaborator

platform:observability is still failing in the latest build - https://github.com/cnti-testcatalog/testsuite/actions/runs/8791269449

Screenshot of the failure below.

CleanShot 2024-04-23 at 04 26 28@2x

Comment on lines 83 to 91
KubectlClient::Get.wait_for_install(deployment_name: "metrics-server")
response_s = `./cnf-testsuite platform:metrics_server poc`
LOGGING.info response_s
(/(PASSED){1}.*(Your platform is using the metrics server){1}/ =~ response_s).should_not be_nil
result = ShellCmd.run_testsuite("platform:metrics_server poc")
(/(PASSED){1}.*(Your platform is using the metrics server){1}/ =~ result[:output]).should_not be_nil
ensure
resp = Helm.uninstall("metrics-server")
LOGGING.info resp
Log.info { resp }
$?.success?.should be_true
end
end
Copy link
Collaborator Author

@kosstennbl kosstennbl Apr 22, 2024

Choose a reason for hiding this comment

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

After some inspection of the changes for the failing test in this PR - it doesn't seem to me that this failure could be brought by them. Changes follow the same redesign rules as all other tests (which seem to be passing). Does this test succeed on other PRs?
@HashNuke

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After further inspection - it seems that it was ensure block, which was causing issues. I'm not sure how and why it started failing after changing only logging for this block, but after last push it should be fine. Please rerun.

Copy link
Collaborator Author

@kosstennbl kosstennbl Apr 23, 2024

Choose a reason for hiding this comment

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

After further inspection - it seems that it was ensure block, which was causing issues. I'm not sure how and why it started failing after changing only logging for this block, but after last push it should be fine. Please rerun.
@HashNuke

REF: cnti-testcatalog#1495
Replace all backtick command execution with ShellCmd module.
Use Log instead of LOGGING module.
Fix edgecase issues caused by logging refactor.
Remove commented-out code.

Signed-off-by: Konstantin Yarovoy <[email protected]>
@kosstennbl
Copy link
Collaborator Author

kosstennbl commented Apr 29, 2024

Rebased after the "output refactor" merge, hopefully i haven't forgot to adapt anything.

@HashNuke
Copy link
Collaborator

HashNuke commented May 7, 2024

@HashNuke HashNuke merged commit 0893b2a into cnti-testcatalog:main May 7, 2024
103 of 178 checks passed
@kosstennbl kosstennbl deleted the backtick_spec_fix branch May 27, 2024 08:34
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.

3 participants