Skip to content

Commit

Permalink
Fix CI regression
Browse files Browse the repository at this point in the history
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
  • Loading branch information
erikbosch committed Jun 21, 2023
1 parent 0334e13 commit aa52dd3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 44 deletions.
26 changes: 4 additions & 22 deletions .github/workflows/kuksa_databroker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,13 @@ jobs:
crate: cargo-strip
version: latest

- uses: actions-rs/[email protected]
with:
crate: cargo2junit
version: latest

- name: Run Tests
- name: Show toolchain information
working-directory: ${{github.workspace}}
run: |
cargo test --all-targets -- -Z unstable-options --report-time --format json | cargo2junit > results.xml;
# - name: Publish test results as PR comment
# uses: EnricoMi/publish-unit-test-result-action@v1
# if: github.event_name == 'pull_request'
# with:
# check_name: Test Results
# github_token: ${{ secrets.GITHUB_TOKEN }}
# files: results.xml

- name: Upload testing report
uses: actions/upload-artifact@v3
with:
name: Unit test results
path: results.xml
rustup toolchain list
cargo --version
- name: Run code coverage
- name: Run tests and report code coverage
run: |
cargo tarpaulin -o Xml
Expand Down
7 changes: 1 addition & 6 deletions kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,6 @@ impl broker::EntryUpdate {
entry: &proto::DataEntry,
fields: HashSet<proto::Field>,
) -> Self {
let path = if fields.contains(&proto::Field::Path) {
Some(entry.path.clone())
} else {
None
};
let datapoint = if fields.contains(&proto::Field::Value) {
entry
.value
Expand All @@ -542,7 +537,7 @@ impl broker::EntryUpdate {
None
};
Self {
path,
path: None,
datapoint,
actuator_target,
entry_type: None,
Expand Down
20 changes: 15 additions & 5 deletions kuksa_databroker/databroker/src/grpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ where
pub async fn serve_with_incoming_shutdown<F>(
stream: TcpListenerStream,
broker: broker::DataBroker,
authorization: Authorization,
signal: F,
) -> Result<(), Box<dyn std::error::Error>>
where
Expand All @@ -162,13 +163,22 @@ where
Server::builder()
.http2_keepalive_interval(Some(Duration::from_secs(10)))
.http2_keepalive_timeout(Some(Duration::from_secs(20)))
.add_service(sdv::databroker::v1::broker_server::BrokerServer::new(
broker.clone(),
))
.add_service(sdv::databroker::v1::collector_server::CollectorServer::new(
.add_service(
sdv::databroker::v1::broker_server::BrokerServer::with_interceptor(
broker.clone(),
authorization.clone(),
),
)
.add_service(
sdv::databroker::v1::collector_server::CollectorServer::with_interceptor(
broker.clone(),
authorization.clone(),
),
)
.add_service(kuksa::val::v1::val_server::ValServer::with_interceptor(
broker.clone(),
authorization,
))
.add_service(kuksa::val::v1::val_server::ValServer::new(broker.clone()))
.serve_with_incoming_shutdown(stream, shutdown(broker, signal))
.await?;

Expand Down
27 changes: 18 additions & 9 deletions kuksa_databroker/databroker/tests/current_values.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/********************************************************************************
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License 2.0 which is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

use core::panic;
use std::{future, time::SystemTime, vec};

use cucumber::{cli, given, then, when, writer, World as _};
use databroker_proto::kuksa::val::v1::{
datapoint::Value, DataEntry, DataType, Datapoint, EntryRequest, EntryType, EntryUpdate, Field,
GetRequest, Metadata, SetRequest, View,
datapoint::Value, DataEntry, DataType, Datapoint, EntryRequest, EntryUpdate, Field, GetRequest,
SetRequest, View,
};
use tracing::debug;
use world::DataBrokerWorld;
Expand Down Expand Up @@ -51,11 +64,7 @@ async fn set_current_value(
path: path.clone(),
value: Some(datapoint),
actuator_target: None,
metadata: Some(Metadata {
data_type: data_type.into(),
entry_type: EntryType::Sensor.into(),
..Default::default()
}),
metadata: None,
}),
fields: vec![Field::Value.into(), Field::Path.into()],
}],
Expand Down Expand Up @@ -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();

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

Expand All @@ -171,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;
}
5 changes: 3 additions & 2 deletions kuksa_databroker/databroker/tests/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ const DATAPOINTS: &[(
#[derive(clap::Args)] // re-export of `clap::Args`
pub struct UnsupportedLibtestArgs {
#[arg(long)]
report_time: bool,
report_time: Option<bool>,
#[arg(long)]
test_threads: u16,
test_threads: Option<u16>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -195,6 +195,7 @@ impl DataBrokerWorld {
grpc::server::serve_with_incoming_shutdown(
tokio_stream::wrappers::TcpListenerStream::new(listener),
data_broker,
grpc::server::Authorization::Disabled,
poll_fn(|cx| {
let mut state = owned_state
.lock()
Expand Down

0 comments on commit aa52dd3

Please sign in to comment.