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

Refactor json output match through out the test script #3823

Closed
4 tasks done
prietyc123 opened this issue Aug 24, 2020 · 3 comments · Fixed by #4296
Closed
4 tasks done

Refactor json output match through out the test script #3823

prietyc123 opened this issue Aug 24, 2020 · 3 comments · Fixed by #4296
Assignees
Labels
area/refactoring Issues or PRs related to code refactoring area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@prietyc123
Copy link
Contributor

prietyc123 commented Aug 24, 2020

/kind code-refactoring

What versions of software are you using?

Operating System:
All supported

Output of odo version:
master

How did you run odo exactly?

Actual behavior

As part of json match is concern it looks pretty weird when we match the whole json (size of a paragraph). If we have a better json parser test script will also look clean and good.

Expected behavior

Instead of matching the whole json we can match the few key field of that. So we need a proper json parser.

Any logs, error output, etc?

Proposed solution

We can use the GJSON (https://github.com/tidwall/gjson) package as it meets the requirements and provides additional flexibility.

Implications:
Will have to refactor all test scripts using the current MatchJSON parser

Acceptance criteria

  • Ability to match one or multiple keys
    Refactor test scripts using the MatchJSON parser from ginkgo:
  • cmd_devfile_url_test.go
  • cmd_pref_config_test.go
  • cmd_app_test

The following tests were updated but reported failures on areas where the changes were not introduced. A new issue will be opened to track their delivery once all other issues are resolved
cmd_dev_file_storage_test.go
cmd_devfile_describe_test.go
cmd_docker_devfile_url_test.go
cmd_storage_test.go
comd_url_test.go
component.go (called by cmd_cmp_test.go and cmd_cmp_sub_test.go)
generic_test.go
cmd_project_test.go

Executed each test as:
ginkgo -randomizeAllSpecs -slowSpecThreshold=120 -timeout 7200s -nodes=1 -focus="[test string in describe section of the test]" [test_path, e.g. tests/integration]

@amitkrout amitkrout added the area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering label Aug 24, 2020
@girishramnani girishramnani added the triage/needs-information Indicates an issue needs more information in order to work on it. label Oct 28, 2020
@rnapoles-rh
Copy link
Contributor

rnapoles-rh commented Oct 28, 2020

@prietyc123 please include a link to the current parser that needs to be refactored, along with a test script that uses it.

@girishramnani
Copy link
Contributor

as discussed @rnapoles-rh we can either just implement a simple map[string]interface{} unmarshalling of the json or consider using https://github.com/tidwall/gjson

@girishramnani girishramnani added the estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person label Oct 29, 2020
@rnapoles-rh rnapoles-rh mentioned this issue Dec 9, 2020
2 tasks
@rnapoles-rh
Copy link
Contributor

The cmd_devfile_storage_test.go test fails in PSI environment, however it runs OK on Prow. Issue #4319 tracks this problem.

openshift-merge-robot pushed a commit that referenced this issue Dec 21, 2020
* 3377 adding odo devfile support test

* #3377 replaced spaces with a Tab

* #3377 updated focus value

* #3823 new func to match JSON path values and updated test scripts to use it

* added . to import

* updated Makefile to aff gjson

* modified Makefile for gjson

* adding go.mo, go.sum and vendor for new gjson dependency

* removed unnecessary changes

* Removed unused import

* Removing if block

* Fixed expected strings for JSON matcher

* Fixed json paths and values to be compared

* Fixed JSON paths and expected values

* fixed required flags for expected failure

* Removed comment in failing code

* Fixed expected output line 164

* removed commented code
@rm3l rm3l added the area/refactoring Issues or PRs related to code refactoring label Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/refactoring Issues or PRs related to code refactoring area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants