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

Allow scheduling a (example) product via the web UI #5933

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Martchus
Copy link
Contributor

@Martchus Martchus commented Sep 17, 2024

Related ticket: https://progress.opensuse.org/issues/166658


Still a draft because I need to add UI tests and move the so far hard-coded data into openqa.ini. It already reads scenario definitions and certain parameters directly from the example distribution, though. Of course this only works if there's a checkout of the example distribution. Maybe we should offer the user to create that checkout in case it is missing (which wouldn't be very hard to do; we'd just add a link on the web UI that'll internally spawn a checkout Minion job we recently implemented anyway).


This is how the menu, the form and success/error messages look like in one screenshot:

grafik

So the test won't fail if we would add other links (e.g. in the navbar).

Related ticket: https://progress.opensuse.org/issues/166658
@okurz
Copy link
Member

okurz commented Sep 18, 2024

overall this looks quite good. I was thinking of alternatives where to place the action but your proposal so far looks like the best to me. Just with the "+" I was thinking of a bigger button, possibly blue, with a frame around to distinguish clearly from the caret

I mean https://fontawesome.com/icons/square-plus?f=classic&s=regular

@Martchus
Copy link
Contributor Author

Martchus commented Sep 18, 2024

I'm pondering about configurability. Reading the structure that has currently the FIXME comment from openqa.ini doesn't really work because it needs nesting but we only use INI. I suppose I could simply read those values from an additional file (e.g. test_presets.ini). Otherwise I could check for sections like [test_presets/example] in openqa.ini but it'll be an additional loop.

EDIT: I guess I'll go for [test_presets/example] because I suppose the additional loop can be avoided.

@Martchus
Copy link
Contributor Author

I now made it configurable. So in this screenshot I overrode the title by putting a [test_presets/example] section to my openqa.ini:

screenshot_20240918_143341

This screenshot also shows that it is now also possible to add additional settings. I think this is important if we want to offer this as a generic form (and the implementation is also quite simple).

This leaves tests and the possibility to clone the example distribution automatically (for the scenario definitions).

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.74%. Comparing base (e88bdd3) to head (3af5894).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5933      +/-   ##
==========================================
+ Coverage   98.73%   98.74%   +0.01%     
==========================================
  Files         395      396       +1     
  Lines       38764    38870     +106     
==========================================
+ Hits        38275    38384     +109     
+ Misses        489      486       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@perlpunk
Copy link
Contributor

I'm pondering about configurability. Reading the structure that has currently the FIXME comment from openqa.ini doesn't really work because it needs nesting but we only use INI. I suppose I could simply read those values from an additional file (e.g. test_presets.ini). Otherwise I could check for sections like [test_presets/example] in openqa.ini but it'll be an additional loop.

EDIT: I guess I'll go for [test_presets/example] because I suppose the additional loop can be avoided.

Config::IniFiles allows groups. You separate the group from the section with a space.
https://metacpan.org/pod/Config::IniFiles#Groups

@Martchus
Copy link
Contributor Author

Config::IniFiles allows groups. You separate the group from the section with a space.
https://metacpan.org/pod/Config::IniFiles#Groups

I now changed it to use e.g. [test_preset foo]. This way we could use the grouping mechanism of the INI parser - even though this is not necessary for the PR in its current form. With this we could use https://metacpan.org/pod/Config::IniFiles#GroupMembers-($group) to show the list of available presets in e.g. the navbar menu. (Not implemented yet. For now I stick to what we have planned in the ticket. So cloning the example repo automatically is probably more important.)

@Martchus Martchus marked this pull request as ready for review September 19, 2024 10:45
@kalikiana
Copy link
Member

Still a draft because I need to add UI tests and move the so far hard-coded data into openqa.ini. It already reads scenario definitions and certain parameters directly from the example distribution, though. Of course this only works if there's a checkout of the example distribution. Maybe we should offer the user to create that checkout in case it is missing (which wouldn't be very hard to do; we'd just add a link on the web UI that'll internally spawn a checkout Minion job we recently implemented anyway).

Is this obsolete? As this is not a draft anymore 😉

kalikiana
kalikiana previously approved these changes Sep 19, 2024
Copy link
Member

@kalikiana kalikiana left a comment

Choose a reason for hiding this comment

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

Looks really nice. Especially with the help texts. And I appreciate your making it extensible in the future.

@Martchus
Copy link
Contributor Author

Martchus commented Sep 19, 2024

I crossed out the obsolete part.

Considering there's remaining work to do I'm still considering this as not ready. We don't want to show a new option prominently that'll not work out of the box.

return undef unless my $ini_config = $config->{ini_config};
my $ini_key = "test_preset $preset_key";
return $presets{$preset_key}
= $ini_config->SectionExists($ini_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't like that we are creating some extra code for this specific feature to handle nested data, while we could do this in a more generic way in Setup.pm with the group feature.
Also it moves any validation we might want to do to runtime instead of server startup.
Since it's something internal we can probably change the implementation later, but just saying.
Not sure what others think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to keep it simple but chose the section name so the group feature can be used in the future for more generic parsing. So if we needed to parse this in a more generic way at some point it'll be possible without a breaking change to the config file format.

@okurz
Copy link
Member

okurz commented Sep 19, 2024

I crossed out the obsolete part.

Considering there's remaining work to do I'm still considering this as not ready. We don't want to show a new option prominently that'll not work out of the box.

Consider a feature switch which should be off by default until we stabilized the feature

@Martchus
Copy link
Contributor Author

I now implemented cloning the example test distribution. So when the user enters the page and the repo hasn't been cloned yet it says "You have to clone the example test distribution first." where the bold part is a link, When clicking on the link one gets a loading indication and after a few seconds (it really doesn't take long to checkout the example distribution) the form reloads with all values filled in. (And in any error case the error is shown and one can retry.) This didn't require adding much code because we already have Minion tasks for cloning from Git now.

@perlpunk
Copy link
Contributor

Btw, we have to be careful to not do this on o3 or osd until fetchneedles is replaced. The example distri has a default branch main, and fetchneedles can't handle different default branches.

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.

Some inline comments.

And have you considered #5933 (comment) ?

etc/openqa/openqa.ini Outdated Show resolved Hide resolved
lib/OpenQA/WebAPI/Controller/Test.pm Show resolved Hide resolved
t/ui/29-create_tests.t Outdated Show resolved Hide resolved
@Martchus
Copy link
Contributor Author

And have you considered #5933 (comment) ?

I only read that comment after I implemented the most recent changes I pushed to this PR yesterday. I don't think it is useful to merge this feature without enabling it by default because it is about the out of the box experience.

@okurz
Copy link
Member

okurz commented Sep 20, 2024

And have you considered #5933 (comment) ?

I only read that comment after I implemented the most recent changes I pushed to this PR yesterday. I don't think it is useful to merge this feature without enabling it by default because it is about the out of the box experience.

I know but do you trust it enough to be enabled on all production instances? After all the primary goal was to show that easy starting point on clean jobless instances

@kalikiana kalikiana dismissed their stale review September 20, 2024 08:59

I guess we are not clear on what we want here afterall

@Martchus
Copy link
Contributor Author

I know but do you trust it enough to be enabled on all production instances?

The feature itself I'd generally consider stable. It has full test coverage. The checkout of the example distribution relies on the Git cloning we implemented a while ago and I don't think it is generally problematic.

I suppose the only problem is fetchneedles cannot handle the use of main as main branch (as opposed to master). At least according to @perlpunk. So I'll have a look at the situation. Maybe that's easy to fix or we can ignore it until fetchneedles is replaced or I can do a manual checkout on our production instances that uses and alias for master.

@Martchus
Copy link
Contributor Author

I added another commit to avoid problems with fetchneedles. See the commit message for details. The short story is that it'll work on our production instances and I also did local test runs of the entire script. There's only one caveat which I don't find problematic but I added a comment in the fetchneedles script documenting it.

script/fetchneedles Outdated Show resolved Hide resolved
* Avoid running into an error when a Git repository like our example
  distribution that does not use the `master` branch anymore is present
* Avoid hard-coding the default branch name for test and needle
  repositories
    * Use `git rev-parse --abbrev-ref refs/remotes/origin/HEAD` instead
      which works with all test and needle repositories we have in our two
      production instances (after I created `.git/refs/remotes/origin/HEAD`
      in the SLE needles checkout; see added comment for details)
    * Keep the possibility to specify `branch` and `needles_branch` in case
      one wants to fetch a special branch
* Tested locally with repos using master and main including the code branch
  for repairing the needle repos
* See https://progress.opensuse.org/issues/166658
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.

Looks very nice now. Fix the code style issues and I am sure I can approve.

@@ -1 +0,0 @@
../../etc/openqa/openqa.ini
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I had to add config values for testing instead of just testing with the default config. (We want to cover the part of the code that allows the users/admins to override values so we obviously need to supply this kind of configuration when running the test.)

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.

Looks very nice now. Fix the code style issues and I am sure I can approve.

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.

4 participants