Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1642 from advancedtelematic/refact/OTA-4814/insta…
Browse files Browse the repository at this point in the history
…ll-on-secondary

Refact/ota 4814/install on secondary
  • Loading branch information
eu-siemann authored Jun 18, 2020
2 parents 93ce187 + c8b6be5 commit d089d8b
Show file tree
Hide file tree
Showing 63 changed files with 2,693 additions and 1,275 deletions.
9 changes: 6 additions & 3 deletions docs/ota-client-guide/modules/ROOT/pages/fault-injection.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ Usage is as follow:

Please try to keep this list up-to-date when inserting/removing fail points.

- `fake_package_download`: force the fake package manager download to fail, optionally with a failure code supplied via `failinfo`
- `fake_package_install`: force the fake package manager installation to fail, optionally with a failure code supplied via `failinfo`
- `secondary_install_xxx` (xxx is a virtual Secondary ECU ID): force a virtual Secondary installation to fail, optionally with a failure code supplied via `failinfo`
- `fake_package_download`: force the fake package manager download to fail
- `fake_package_install`: force the fake package manager installation to fail
- `fake_install_finalization_failure`: force the fake package manager installation finalization to fail
- `secondary_putmetadata`: force virtual Secondary metadata verification to fail
- `secondary_putroot`: force virtual Secondary Root rotation to fail
- `secondary_sendFirmware_xxx` (xxx is a virtual Secondary ECU ID): force a virtual Secondary firmware send to fail
- `secondary_install_xxx` (xxx is a virtual Secondary ECU ID): force a virtual Secondary installation to fail

== Use in unit tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ For description of all configuration options, refer to the client configuraton x
+
[source,cpp]
----
void Aktualizr::AddSecondary(const std::shared_ptr<Uptane::SecondaryInterface> &secondary)
void Aktualizr::AddSecondary(const std::shared_ptr<SecondaryInterface> &secondary)
----
You must call this function before you call `Initialize`. To find out more about Primary and Secondary ECUs, see our xref:uptane.adoc#_primary_and_secondary_ecus[Uptane description].

Expand Down
9 changes: 5 additions & 4 deletions src/aktualizr_primary/secondary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Primary {

using Secondaries = std::vector<std::shared_ptr<Uptane::SecondaryInterface>>;
using Secondaries = std::vector<std::shared_ptr<SecondaryInterface>>;
using SecondaryFactoryRegistry =
std::unordered_map<std::string, std::function<Secondaries(const SecondaryConfig&, Aktualizr& aktualizr)>>;

Expand All @@ -27,7 +27,8 @@ static SecondaryFactoryRegistry sec_factory_registry = {
return createIPSecondaries(ip_sec_cgf, aktualizr);
}},
{VirtualSecondaryConfig::Type,
[](const SecondaryConfig& config, Aktualizr& /* unused */) {
[](const SecondaryConfig& config, Aktualizr& aktualizr) {
(void)aktualizr;
auto virtual_sec_cgf = dynamic_cast<const VirtualSecondaryConfig&>(config);
return Secondaries({std::make_shared<VirtualSecondary>(virtual_sec_cgf)});
}},
Expand Down Expand Up @@ -71,7 +72,7 @@ class SecondaryWaiter {
endpoint_{boost::asio::ip::tcp::v4(), wait_port},
timeout_{static_cast<boost::posix_time::seconds>(timeout_s)},
timer_{io_context_},
connected_secondaries_(secondaries) {}
connected_secondaries_{secondaries} {}

void addSecondary(const std::string& ip, uint16_t port) { secondaries_to_wait_for_.insert(key(ip, port)); }

Expand Down Expand Up @@ -164,7 +165,7 @@ static Secondaries createIPSecondaries(const IPSecondariesConfig& config, Aktual
auto secondaries_info = aktualizr.GetSecondaries();

for (const auto& cfg : config.secondaries_cfg) {
Uptane::SecondaryInterface::Ptr secondary;
SecondaryInterface::Ptr secondary;
const SecondaryInfo* info = nullptr;

// Try to match the configured Secondaries to stored Secondaries.
Expand Down
23 changes: 11 additions & 12 deletions src/aktualizr_secondary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ set(AKTUALIZR_SECONDARY_SRC main.cc)
set(AKTUALIZR_SECONDARY_LIB_SRC
update_agent_file.cc
aktualizr_secondary.cc
aktualizr_secondary_factory.cc
aktualizr_secondary_file.cc
aktualizr_secondary_config.cc
aktualizr_secondary_metadata.cc
secondary_tcp_server.cc
msg_dispatcher.cc
msg_handler.cc
)

# do not link tests with libaktualizr
Expand Down Expand Up @@ -44,12 +44,11 @@ set(ALL_AKTUALIZR_SECONDARY_HEADERS
update_agent.h
update_agent_file.h
aktualizr_secondary.h
aktualizr_secondary_factory.h
aktualizr_secondary_file.h
aktualizr_secondary_config.h
aktualizr_secondary_metadata.h
secondary_tcp_server.h
aktualizr_secondary_interface.h
msg_dispatcher.h
msg_handler.h
)

# insert in front, so that the order matches the dependencies to the system libraries
Expand All @@ -58,13 +57,13 @@ list(INSERT TEST_LIBS 0 aktualizr_secondary_lib)
add_aktualizr_test(NAME aktualizr_secondary_config
SOURCES aktualizr_secondary_config_test.cc PROJECT_WORKING_DIRECTORY LIBRARIES aktualizr_secondary_lib)

add_aktualizr_test(NAME secondary_rpc
SOURCES secondary_rpc_test.cc PROJECT_WORKING_DIRECTORY)
add_aktualizr_test(NAME secondary_rpc SOURCES $<TARGET_OBJECTS:primary> $<TARGET_OBJECTS:http> secondary_rpc_test.cc PROJECT_WORKING_DIRECTORY)
list(REMOVE_ITEM TEST_SOURCES $<TARGET_OBJECTS:primary> $<TARGET_OBJECTS:http>)

if(BUILD_OSTREE)
target_sources(aktualizr_secondary_lib PRIVATE update_agent_ostree.cc)
list(APPEND AKTUALIZR_SECONDARY_LIB_SRC update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)
target_sources(aktualizr_secondary_lib PRIVATE update_agent_ostree.cc aktualizr_secondary_ostree.cc)
list(APPEND AKTUALIZR_SECONDARY_LIB_SRC update_agent_ostree.cc aktualizr_secondary_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h aktualizr_secondary_ostree.h)

add_aktualizr_test(NAME aktualizr_secondary_ostree
SOURCES aktualizr_secondary_ostree_test.cc
Expand All @@ -74,8 +73,8 @@ if(BUILD_OSTREE)

set_target_properties(t_aktualizr_secondary_ostree PROPERTIES LINK_FLAGS -Wl,--export-dynamic)
else(BUILD_OSTREE)
list(APPEND TEST_SOURCES aktualizr_secondary_ostree_test.cc update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)
list(APPEND TEST_SOURCES aktualizr_secondary_ostree_test.cc update_agent_ostree.cc aktualizr_secondary_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h aktualizr_secondary_ostree.h)
endif(BUILD_OSTREE)

add_aktualizr_test(NAME aktualizr_secondary
Expand Down
Loading

0 comments on commit d089d8b

Please sign in to comment.