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

gradle discrepancies #33

Open
8 tasks done
zeners opened this issue Apr 19, 2024 · 47 comments
Open
8 tasks done

gradle discrepancies #33

zeners opened this issue Apr 19, 2024 · 47 comments

Comments

@zeners
Copy link
Contributor

zeners commented Apr 19, 2024

i found the following needed actions, please correct me, if i'm wrong

  • SerenityTask need removing clearHistory and history as mentioned by @petrandreev
  • build.gradle should use tasks.register
  • .all should be replaces with configureEach in build.gradle
  • test-Task need useJUnitPlatform() to run the tests
  • what's happen to remove newly introduced and unnecessary generateOutcomes property #30 ?
  • JUnit5-test-classes should be package-private
  • contains-assertions should be written as assertThat(...).contains(...); (currently assertThat(....contains(...));
  • create README-file with detailed usage descriptions

i tested the actions with a simple test-project and with active --build-cache --configuration-cache
getting the following result:

  • clean test without change: create empty result
     > Task :test FROM-CACHE
     > Task :aggregate
    
  • test after change: create index with no results pages listed (after clean test)
    > Task :test
    > Task :aggregate UP-TO-DATE
    

this looks like test create output, that aggregate uses without the knowledge of gradle-cache

gradle writes output into build, serenity into target/site/serenity, clean only remove serenity inside target/site

@petrandreev
Copy link

hi @zeners, regarding your Q about generateOutcomes, not needed before- it's been changed here:3424830
It used to be always set, now one needs to set it to "true" on PluginExtension explicitely.
Thanks for summing up

@zeners zeners mentioned this issue Apr 21, 2024
@zeners
Copy link
Contributor Author

zeners commented Apr 21, 2024

i can't test the deployment, so i hope that i didn't broke something

@wakaleo
Copy link
Member

wakaleo commented Apr 21, 2024

Just published the new version, feel free to test

@zeners
Copy link
Contributor Author

zeners commented Apr 21, 2024

@wakaleo thank you

the cache doesn't work as expected. I'm afraid that we have to use the complete outputDirectory from test.

  • gradle clean test -x aggregate --build-cache --configuration-cache should create the test-result without report:
    ...
    > Task :test 
    
    
  • gradle clean test --build-cache --configuration-cache should build the reports, based on cached test output
    > Task :test FROM-CACHE
    > Task :aggregate
    Generating Serenity Reports
    

but the generated report is empty, because the test-results are missing
will try to write a test addressing this

@tnielens
Copy link
Contributor

Hi here,
Sorry to jump in. Was #19 reverted? From what I tested only #30 to fix the missing test results needed to be merged for it to work properly. Internally we're using a published version including #30 and we observe no issues with the plugin.

@zeners
Copy link
Contributor Author

zeners commented Apr 23, 2024

c7e0310 was an undo of #19, but 3424830 makes a redo, but with differences

currently i'm afraid that's not possible to make a consistent result, if you test without aggegate (test -x aggregate) and after it clean test will run aggregate without test-results, not restored from cache.

i have a plan in mind, but need some time to implement and test

@tnielens
Copy link
Contributor

Thanks for clarifying.

As for aggregate, we don't understand well its behavior as it doesn't play well with the project-scoped expectation of gradle. That task seems to collect outputs from all subprojects in a multimodule project although the task exists in each project. Also the static/global state of serenity prevents use of gradle parallelism and running parallel tasks in a multi-module project leads to concurrency issues in serenity tasks and outputs.

Aside of these issues, #19 was a welcome improvement 👍.

@zeners
Copy link
Contributor Author

zeners commented Apr 25, 2024

That task seems to collect outputs from all subprojects in a multimodule project although the task exists in each project.

assuming the gradle-plugin should work like the maven-plugin, as outlined in serenity-bdd/serenity-maven-plugin#22 (comment) you have to set a common output-directory in all subprojects, to get one report for all subproject tests, correct?

@petrandreev
Copy link

petrandreev commented Apr 25, 2024

Solved reports generation issue in a muli-module project with v 4.1.10 (happens on RH UBI, e.g. linux, not on Mac though...) on my side.
IMHO the issue has nothing to do with gradle cache(s) -

  1. test task (JSONTestOutcomeReporter actually) generates reports into serenity.conf's outputDirectory (build/site/serenity)
  2. on aggregate task, Gradle decides that the whole directory, configured by serenity plugin extension's outputDirectory is stale and deletes it!:
> Task :serenity:aggregate
Deleting stale output file: ......../build/site/serenity
  1. aggregator has nothing to work with since no JSON outcomes - no reports in the site HTML!

The both configured outputDirectory s must point to the same location- otherwise JSON reports are not picked up for further processing, not sure why....

Solution:
declare either

  • input of aggregate task to be build/site/serenity directory or
  • output of the test task to be build/site/serenity directory

Gradle then takes into account that there could be some other output, besides aggregate's one, and doesn't delete the entire build/site/serenity directory- aggregate picks JSONs up and produces HTML report.

P.S. thanks to @tnielens - yes i forgot to mention that this setup is not recommended by gradle - but I currently I don't see any other way to generate reports- it doesn't work otherwise...

@tnielens
Copy link
Contributor

Gradle incremental build and task cache (to be distinguished from the configuration cache) don't work reliably if multiple tasks output results in the same directory. You'll see warnings in the log about this.

@zeners
Copy link
Contributor Author

zeners commented Apr 27, 2024

  • test-results are not only the json-files, but also can (at least) include downloadable and (screenshot)pictures
  • these outputs should be known to gradle and connected via input/output between the task
  • the connection of output and input creates a direct dependency between these 2 tasks (test and aggregate)
  • i like to see test and aggregate be separate to call (now you have to exclude aggregate, when running test, but that's ok)

we can copy the test-result-files to a aggregate-working directory to split the test-output from the aggregate output - but this would be a breaking change

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

I'm reverting all of these changes as they have caused a number of regressions.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

wich ones?

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

serenity-bdd/serenity-core#3468

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

we should found a way to go with configuration cache

@tnielens
Copy link
Contributor

tnielens commented May 22, 2024

@wakaleo are we back with #19 merged and the small fix #30 as well?
That's what we run in my org, and it works fine, configuration cache included. Some issues with overlapping output directories for the task cache, but nothing blocking so far.

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

@wakaleo are we back with #19 merged and the small fix #30 as well?

I'm rolling back all the changes. There are too many issues being raised and I don't have time or the Gradle knowledge to deal with them.

@tnielens
Copy link
Contributor

As said above, if you include #30, #19 works fine. I can provide support to iron out issues and increase the test coverage.

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

As said above, if you include #30, #19 works fine. I can provide support to iron out issues and increase the test coverage.

#30 was included in the code base. I will roll it all back and you are welcome to redo the PRs, but we need an up to date sample project as the Gradle unit tests don't pick up all the issues.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

would be nice to run tests before merged

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

would be nice to run tests before merged

To run the full test suite you need to publish the plugin - if you can find a way to run end-to-end tests with the Gradle plugin without needing to publish it that could work better.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

that's that the tests currently do, no need to be published previuosly

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

that's that the tests currently do, no need to be published previuosly

There are unit tests, but since Groovy is a dynamic language they don't pick up all the issues, which only appear when you run the plugin against a real project. If you know how to write local end-to-end tests that do pick up these issues that would be a great help.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

could github run these tests on PR as an action?

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

No, because if you run them against a project separately, you need to publish the plugin first which can only be done by hand. (We do run the Gradle unit tests for each build, but they are not sufficient).

@tnielens
Copy link
Contributor

@wakaleo gradle has great support for e2e tests (they call it functional tests). Doesn't this suite fulfill your requirements?

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

currently tests are insufficient: accepted
the only check currently run is the GitGuardian Security Checks
i like to see the tests running as check on PR

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

@wakaleo gradle has great support for e2e tests (they call it functional tests). Doesn't this suite fulfill your requirements?

No it does not. We get lots of errors appearing when we actually try the tests out on a real project that don't appear in these tests.

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

currently tests are insufficient: accepted the only check currently run is the GitGuardian Security Checks i like to see the tests running as check on PR

Can you propose a PR on the Github actions to do this?

@tnielens
Copy link
Contributor

The current test coverage in the project is gappy. We can add a lot more test cases. The multi module test suite was added to cover a particular failure scenario.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

Can you propose a PR on the Github actions to do this?

i'm not familiar with github actions, will take a look, will need time, maybe someone is faster ;)

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

The current test coverage in the project is gappy. We can add a lot more test cases. The multi module test suite was added to cover a particular failure scenario.

More tests would be very welcome.

@tnielens
Copy link
Contributor

#19 added several tests which were reverted unfortunately. I suppose they can be reapplied without the main code patch easily.

@tnielens
Copy link
Contributor

For github actions, here is some doc by gradle: https://docs.gradle.org/current/userguide/github-actions.html#sec:configure_github_actions . I'll try that out.

@tnielens
Copy link
Contributor

There was a workflow already in place, but it didn't run on PR: #35 .

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

it works, the tests failed:

2024-05-22T10:41:17.7088829Z ExplicitTaskDependenciesTest > explicitDependencyBetweenClearReportsAndCheckOutcomes() FAILED
2024-05-22T10:41:17.7090682Z     org.gradle.testkit.runner.UnexpectedBuildFailure at ExplicitTaskDependenciesTest.java:78
2024-05-22T10:41:18.6085785Z 
2024-05-22T10:41:18.6086694Z MultiModuleTest > multiModulesAggregateTheReportInTheRightLocation() FAILED
2024-05-22T10:41:18.6087995Z     org.gradle.testkit.runner.UnexpectedBuildFailure at MultiModuleTest.java:94

@tnielens
Copy link
Contributor

@zeners see the comments in the PR. The current master revision is broken it seems. The plugin cannot register certain tasks.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

that have been fixed and is now rolled back?

@tnielens
Copy link
Contributor

@wakaleo patched master. The tests now pass.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

so we have now a working master and checked test on PR: thanks!

@tnielens
Copy link
Contributor

@zeners what are your plans here. Do you intend to resubmit your changes? I'd like to resubmit the configuration cache support originally submitted in #19 but would like to avoid working on the same tasks as you.

@zeners
Copy link
Contributor Author

zeners commented May 22, 2024

@tnielens i would like to resubmit, after having tests for the issues, but it will take some time (may be at weekend)
please feel free to start

@tnielens
Copy link
Contributor

for my understanding, did any of your changes concern the configuration cache?

@wakaleo
Copy link
Member

wakaleo commented May 22, 2024

for my understanding, did any of your changes concern the configuration cache?

No

@zeners
Copy link
Contributor Author

zeners commented Jun 1, 2024

@tnielens any news/progress?

@tnielens
Copy link
Contributor

tnielens commented Jun 1, 2024

No. I haven't started yet. I intended to start from the former configuration cache PR #19 plus my small fix #30. Feel free to take a head start if you wanna work on this this weekend.

@tnielens
Copy link
Contributor

@zeners @wakaleo I just checked latest revision 5ee4d91 on master. I don't face any configuration cache issues. Not sure what you reverted @wakaleo but as far as I checked, the configuration cache is functional with the serenity plugin applied.

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

No branches or pull requests

4 participants