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

Validate parameters passed to job group API routes #2812

Merged
merged 1 commit into from
Apr 1, 2020

Conversation

kalikiana
Copy link
Member

See also #2781 for validation in JobTemplate.

See: poo#64075

@kalikiana kalikiana self-assigned this Mar 3, 2020
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

nice :)

lib/OpenQA/WebAPI/Plugin/Helpers.pm Outdated Show resolved Hide resolved
t/api/10-jobgroups.t Outdated Show resolved Hide resolved
t/api/10-jobgroups.t Outdated Show resolved Hide resolved
@okurz
Copy link
Member

okurz commented Mar 10, 2020

+1

UI test failed with:

[08:25:33] t/ui/13-admin.t ............................ 11/? 
        #   Failed test 'size edited'
        #   at t/ui/13-admin.t line 471.
        #          got: '1000'
        #     expected: ''
        # Looks like you failed 1 test of 10.

    #   Failed test 'edit some properties'
    #   at t/ui/13-admin.t line 472.
    # Looks like you failed 1 test of 4.
[08:25:33] t/ui/13-admin.t ............................ 12/? 
#   Failed test 'job property editor'
#   at t/ui/13-admin.t line 473.
    # products: {}\nscenarios: {} # additional comment\n
[08:25:33] t/ui/13-admin.t ............................ 15/? # Looks like you failed 1 test of 15.
[08:25:33] t/ui/13-admin.t ............................ Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/15 subtests

@kalikiana
Copy link
Member Author

+1

UI test failed with:

[08:25:33] t/ui/13-admin.t ............................ 11/? 
        #   Failed test 'size edited'
        #   at t/ui/13-admin.t line 471.
        #          got: '1000'
        #     expected: ''
        # Looks like you failed 1 test of 10.

    #   Failed test 'edit some properties'
    #   at t/ui/13-admin.t line 472.
    # Looks like you failed 1 test of 4.
[08:25:33] t/ui/13-admin.t ............................ 12/? 
#   Failed test 'job property editor'
#   at t/ui/13-admin.t line 473.
    # products: {}\nscenarios: {} # additional comment\n
[08:25:33] t/ui/13-admin.t ............................ 15/? # Looks like you failed 1 test of 15.
[08:25:33] t/ui/13-admin.t ............................ Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/15 subtests

After spending considerable time debugging this, my finding is this: $self-validation->param consistently returns no value if the value is indeed '' as can be the case with size_limit_gb regardless of errors or even without any regex defined. So I changed it back to $self->param and added a XXX comment.

@kalikiana kalikiana marked this pull request as ready for review March 16, 2020 08:56
@kraih
Copy link
Member

kraih commented Mar 16, 2020

I've proposed an upstream change that might help with this. mojolicious/mojo#1482

Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

I guess it is best if @kraih give a review because he knows best how the validator API is supposed to be used.

t/api/10-jobgroups.t Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 16, 2020

Codecov Report

Merging #2812 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2812      +/-   ##
==========================================
+ Coverage   93.27%   93.29%   +0.02%     
==========================================
  Files         189      189              
  Lines       11917    11912       -5     
==========================================
- Hits        11115    11113       -2     
+ Misses        802      799       -3
Impacted Files Coverage Δ
lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm 98.27% <100%> (+0.25%) ⬆️
lib/OpenQA/Schema/Result/JobModules.pm 93.9% <0%> (-0.36%) ⬇️
lib/OpenQA/Schema/Result/Jobs.pm 97.03% <0%> (-0.02%) ⬇️
lib/OpenQA/WebAPI/Plugin/ObsRsync.pm 99.17% <0%> (-0.01%) ⬇️
lib/OpenQA/Worker/Job.pm 74.59% <0%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b26b51b...4495ec4. Read the comment docs.

@kalikiana kalikiana changed the title Validation and docs for JobGroup create and update Validate parameters passed to job group API routes Mar 30, 2020
t/api/10-jobgroups.t Outdated Show resolved Hide resolved
Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

Let's see whether the tests pass.

{keep_important_logs_in_days => '4 days'},
{keep_results_in_days => '30 days'},
{keep_important_results_in_days => '1 days'},
{default_priority => 'inherit'},
Copy link
Contributor

@Martchus Martchus Mar 31, 2020

Choose a reason for hiding this comment

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

It would actually make sense to allow this so one can revert to the inherited value. But it looks like that is really not supported so far so I'm fine considering this invalid at this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, and since we support that with job templates one could be forgiven for trying to use that. So I picked the invalid value here as well to highlight that it is not supported.

lib/OpenQA/WebAPI/Controller/API/V1/JobGroup.pm Outdated Show resolved Hide resolved
t/api/10-jobgroups.t Outdated Show resolved Hide resolved
@Martchus Martchus merged commit 21e083f into os-autoinst:master Apr 1, 2020
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.

5 participants