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

Fix nightly #582

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Fix nightly #582

merged 1 commit into from
Jun 21, 2023

Conversation

erikbosch
Copy link
Contributor

@erikbosch erikbosch commented Jun 19, 2023

Testing how we can get rid of the problem with -Z errors.

@erikbosch erikbosch marked this pull request as draft June 19, 2023 07:18
@erikbosch erikbosch force-pushed the erik_nightly branch 6 times, most recently from 1d04eb9 to 556a8bb Compare June 19, 2023 09:15
@argerus argerus force-pushed the erik_nightly branch 2 times, most recently from 47b5fff to 3278b9c Compare June 19, 2023 21:09
@@ -63,6 +63,11 @@ jobs:
- name: Install Protoc
run: sudo apt-get install -y protobuf-compiler
- uses: actions/checkout@v3
- name: Install minimal nightly
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a really a good idea to REQUIRE nightly toolchains to buold databroker (if I understand correctly)

If so, what is our really, really good reason for it?

Copy link
Contributor Author

@erikbosch erikbosch Jun 20, 2023

Choose a reason for hiding this comment

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

If I understand things correctly.

  • This installs the nightly toolchain, but the nightly toolchain is only used if requested
  • We need the nightly toolchain for our test, at least as long as we want to use --report-time which is an unstable option and thus (most of the time?) only available in nightly tool-chain. I actually do not know why this test has worked now and then in the past. If "default" sometimes have been nightly anyway? I actually do not know what controls what cargo version we use for building, i.e. how that is controlled
  • The nightly will only be used when we use +nightly

I guess we alternatively could refactor the test case to not rely on the unstable feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did some tests removing --report-time and the json report format (which also is experimental). The problem then is that it seems difficult to capture the test result. On failure exit code is still 0, and it is not as easy as searching for "failure" or "error" in stdout it seems. So in short, verifying test results seems easier if using nightly. The main build of databroker anyway happen inside the docker container, so whatever we set in the *.yml file should not matter.

Copy link
Contributor

@argerus argerus Jun 20, 2023

Choose a reason for hiding this comment

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

Yes, nightly is only used for running the tests (not building databroker), and as Erik mentions it's needed only if we want these output files.

Originally, this output was used to create a Github comment in the corresponding PR with a fancy test summary. This was removed because of lack of permissions when migrated to the kuksa repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this does not influence the "container builds", but doing this, are we not essentially also building databroker used for the tests with a nightly toolchain? I.e. what we test is build with a different toolchain than what we release (I do understand, this was not perfectly in sync before, except for the integration tests, but now it is nightly vs. stable).

If this is the only (simple) way, maybe we need to live with it for now. Just want to confirm whether my understanding is correct. (and why did this even break now?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My theory so far:

If you look at old "successful" builds like https://github.com/eclipse/kuksa.val/actions/runs/5120892422/jobs/9207950580 you can see that they anyway was not successful, there are errors like:

 error: the following required arguments were not provided:
  --test-threads <TEST_THREADS>

(but they did not cause the build to fail which is a bit strange IMHO)

As I said before, we could remove the dependency and instead try to do some greps on the output of the tests and that way try to figure out if there are any errors. Just let me know if you think that is the preferred approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

cargo test does return non-successful return codes when a test fails. At least for the "normal" tests.

So, I think the issue is specific to the cucumber tests and it's runner.

#[tokio::main]
async fn main() {
    // databroker::init_logging();

    let opts = cli::Opts::<_, _, _, world::UnsupportedLibtestArgs>::parsed();

    DataBrokerWorld::cucumber()
        .with_writer(writer::Libtest::or_basic())
        .with_cli(opts)
        .after(|_feature, _rule, _scenario, _ev, world| {
            if let Some(w) = world {
                w.stop_databroker();
            }
            Box::pin(future::ready(()))
        })
        .run("tests/features/current_values.feature")
        .await;
}

So I think the preferred solution is to modify this runner to return non-success on test failures.

Separate from that, we might at some point want to report the results of our unit tests in some fancy way (again), which might require unstable features. But for simple success / failure, I don't think it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know how to achieve this in the cucumber runner? Maybe @sophokles73 knows or @rafaeling has looked into the cucumber magic already?

I agree with @erikbosch we should repair CI fast, but if there is a "similarly" easy way to achieve this without adding deps on "nightly" toolchain (that just "feels" bad to me) I would prefer that

In that case we could revisit "fancy" reporting later, but since we as of today are not using it anyway we wouldn't loose anything...

Copy link
Contributor

@argerus argerus Jun 20, 2023

Choose a reason for hiding this comment

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

Replacing run with run_and_exit seems to do the trick..

diff --git a/kuksa_databroker/databroker/tests/current_values.rs b/kuksa_databroker/databroker/tests/current_values.rs
index a174f37..82183ce 100644
--- a/kuksa_databroker/databroker/tests/current_values.rs
+++ b/kuksa_databroker/databroker/tests/current_values.rs
@@ -180,6 +180,6 @@ async fn main() {
             }
             Box::pin(future::ready(()))
         })
-        .run("tests/features/current_values.feature")
+        .run_and_exit("tests/features/current_values.feature")
         .await;
 }

broker.clone(),
authorization,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@argerus - don't we need clone here as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, we don't use it (further) after this point.

(and if clone() was actually needed, it wouldn't compile)

@@ -158,7 +167,7 @@ fn assert_set_request_failure(w: &mut DataBrokerWorld, path: String, expected_er

#[tokio::main]
async fn main() {
databroker::init_logging();
// databroker::init_logging();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@argerus - shall we better keep or remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a test, I left it there as someone at some point found it useful.

I guess a "better" option would be to turn down the default log level, but I didn't put any effort into it.

@erikbosch erikbosch marked this pull request as ready for review June 20, 2023 07:13
@erikbosch
Copy link
Contributor Author

@SebastianSchildt - could you check if the PR is acceptable from your side. If we want to refactor test cases to not use experimental features we could do it later, for me the most important short time solution is to make sure CI works.

@argerus
Copy link
Contributor

argerus commented Jun 20, 2023

If we want to refactor test cases to not use experimental features

I don't think the test cases use any experimental features. Only the test reporting.

@erikbosch erikbosch force-pushed the erik_nightly branch 2 times, most recently from 4919e98 to 512338c Compare June 21, 2023 06:43
Fixes two problems

- Previous test config requires nightly, so an error is received if "stable"
  does not happen to be "nightly" as well
- We anyway did not provide enough arguments, but no error was given

Solution is to just run coverage and remove the JSON report format.
Everything is anyhow present in log.
Also fixing rust code so tests pass and errors make test fail
@erikbosch
Copy link
Contributor Author

@SebastianSchildt @argerus

Now the dependency to experimental features are gone.
I actually removed the whole "cargo test" section as the tests are included as well when you do the tarpaulin part to get coverage. I verified that the build fails if there is an error in the cucumber tests.

working-directory: ${{github.workspace}}
run: |
cargo test --all-targets -- -Z unstable-options --report-time --format json | cargo2junit > results.xml;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove the "unstable part" we cannot do the result upload part. less important as I see it as the log anyway is visible in stdout.
But if we do not have the report part there is no need to have it as tests anyway are run by "cargo tarpaulin" below

Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

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

looking good to me

@erikbosch erikbosch merged commit aa52dd3 into eclipse:master Jun 21, 2023
@erikbosch erikbosch deleted the erik_nightly branch June 21, 2023 14:42
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