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

udev: Improve testability and tests #582

Merged
merged 4 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-test-cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://dl.k8s.io/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "agent"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>", "<bfjelds@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion controller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "controller"
version = "0.10.5"
version = "0.10.6"
authors = ["<bfjelds@microsoft.com>", "<kagold@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.10.5
version: 0.10.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 0.10.5
appVersion: 0.10.6
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "debug-echo-discovery-handler"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onvif-discovery-handler"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opcua-discovery-handler"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-discovery-handler"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/debug-echo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-debug-echo"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-onvif"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/opcua/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-opcua"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/udev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-udev"
version = "0.10.5"
version = "0.10.6"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
23 changes: 5 additions & 18 deletions discovery-handlers/udev/src/discovery_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{
discovery_impl::{do_parse_and_find, get_device_relatives, DeviceProperties},
discovery_impl::{do_parse_and_find, insert_device_with_relatives, DeviceProperties},
wrappers::udev_enumerator,
};
use akri_discovery_utils::discovery::{
Expand All @@ -12,7 +12,7 @@ use akri_discovery_utils::discovery::{
};
use async_trait::async_trait;
use log::{error, info, trace};
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::time::Duration;
use tokio::sync::mpsc;
use tokio::time::sleep;
Expand Down Expand Up @@ -71,28 +71,15 @@ impl DiscoveryHandler for DiscoveryHandlerImpl {
}
break;
}
let mut devpaths: HashMap<String, Vec<DeviceProperties>> = HashMap::new();
let mut devpaths: HashMap<String, HashSet<DeviceProperties>> = HashMap::new();
udev_rules.iter().for_each(|rule| {
let enumerator = udev_enumerator::create_enumerator();
let paths = do_parse_and_find(enumerator, rule).unwrap();
for path in paths.into_iter() {
if !discovery_handler_config.group_recursive {
devpaths.insert(path.0.clone(), vec![path]);
devpaths.insert(path.0.clone(), HashSet::from([path]));
} else {
match get_device_relatives(&path.0, devpaths.keys()) {
(Some(parent), _) => devpaths.get_mut(&parent).unwrap().push(path),
(None, children) => {
let id = path.0.clone();
let mut children_devices: Vec<DeviceProperties> = children
.into_iter()
.flat_map(|child| {
devpaths.remove(&child).unwrap().into_iter()
})
.collect();
children_devices.push(path);
let _ = devpaths.insert(id, children_devices);
}
}
insert_device_with_relatives(&mut devpaths, path);
}
}
});
Expand Down
Loading