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

Feat/ota 2282/more failure simulation #1145

Merged
merged 10 commits into from
Mar 22, 2019

Conversation

lbonn
Copy link
Contributor

@lbonn lbonn commented Mar 18, 2019

Based on #1144.

In a nutshell:

  • keep a stable ecu order (what's given in StoreEcuSerials)
  • device installation result code contains a concatenation of ecu_type:error in case of error
  • added functionality on top of libfiu, uses temporary files as storage for strings

Will add a test for the changes in SotaUptaneClient::computeDeviceInstallationResult when ready

@OYTIS
Copy link
Contributor

OYTIS commented Mar 18, 2019

This pull request introduces 2 alerts when merging ad132cc into 935e0ce - view on LGTM.com

new alerts:

  • 2 for Illegal raise

Comment posted by LGTM.com

@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch from ad132cc to 8ef5496 Compare March 19, 2019 09:11
@codecov-io
Copy link

codecov-io commented Mar 19, 2019

Codecov Report

Merging #1145 into master will increase coverage by 0.09%.
The diff coverage is 94.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
+ Coverage   77.74%   77.83%   +0.09%     
==========================================
  Files         167      167              
  Lines        9947     9994      +47     
==========================================
+ Hits         7733     7779      +46     
- Misses       2214     2215       +1
Impacted Files Coverage Δ
src/libaktualizr/primary/aktualizr.h 100% <ø> (ø) ⬆️
src/libaktualizr/primary/sotauptaneclient.h 100% <ø> (ø) ⬆️
...libaktualizr/package_manager/packagemanagerfake.cc 93.47% <100%> (+0.14%) ⬆️
src/libaktualizr/storage/sqlstorage.cc 74.02% <100%> (ø) ⬆️
src/libaktualizr/primary/sotauptaneclient.cc 87.04% <80%> (-0.12%) ⬇️
src/libaktualizr/utilities/types.cc 68.75% <92.3%> (+2.67%) ⬆️
src/libaktualizr/utilities/fault_injection.h 97.14% <97.05%> (-2.86%) ⬇️
src/libaktualizr/storage/sqlstorage_base.cc 78.12% <0%> (+2.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d91282a...cccfa33. Read the comment docs.

@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch 5 times, most recently from abcfec6 to 989118c Compare March 20, 2019 17:35
@lbonn lbonn removed the not-ready label Mar 21, 2019
@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch from 989118c to fb7ba7e Compare March 21, 2019 10:21
@lbonn
Copy link
Contributor Author

lbonn commented Mar 21, 2019

Ok I've cleaned a bit the CMake invocations for running test_fiuinfo.

Last things on my list:

  • cleaning up the unit test (last commit)
  • actions.md
  • changelog

But the bulk of the work is ready for review.

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

Looks good so far!

for (auto it = serials.cbegin() + 1; it != serials.cend(); it++) {
auto statement = db.prepareStatement<int64_t, std::string, std::string>(
"INSERT INTO ecu_serials(id,serial,hardware_id) VALUES (?,?,?);", it - serials.cbegin(), it->first.ToString(),
it->second.ToString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the ID is just purely for sequencing, and we just trust that what we receive from the server is the order we should maintain? Not a bad idea to finally make it explicit instead of assuming primary is always first.

Copy link
Contributor Author

@lbonn lbonn Mar 21, 2019

Choose a reason for hiding this comment

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

Yes, the id is for sequencing.

I don't believe the order comes from the server, but the local config:

storage_->storeEcuSerials(ecu_serials);

Hope I haven't overlooked anything but the intent is that any two devices with the same configuration (i.e: with same sets of ecu, deducted from configuration files named the same) would have their ecus in the same order, so that we can safely match them with the same device error code if several ecus fail.

e.g: ecu1:fail1|ecu2:fail2 and never ecu2:fail2|ecu1:fail1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bad idea to finally make it explicit instead of assuming primary is always first.

The api still expects a list of serials that start with the primary.


Aktualizr aktualizr(conf, storage, http);

// TODO: was stolen from other test, refactor
Copy link
Collaborator

Choose a reason for hiding this comment

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

uh-oh, a TODO!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, refactored a bit

TEST(Fiuinfo, PassInfoWithCtrl) {
EXPECT_EQ(fiu_fail("failctrl"), 0);
Utils::shell(fiu_script + " ctrl -c 'enable name=failctrl,failinfo=test_ctrl' " + std::to_string(getpid()), nullptr);
EXPECT_NE(fiu_fail("failctrl"), 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed, I think checking that we can unset the failure and recover is worthwhile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be covered now.

@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch from fb7ba7e to a51704b Compare March 21, 2019 15:03
@lbonn
Copy link
Contributor Author

lbonn commented Mar 21, 2019

Pushed minor changes in the fault injection part, as it was needlessly depending on having unsigned long strictly bigger than 32 bits. Plus, in-line comments to make the inner workings clearer.

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

Looking even better!


TEST(Fiuinfo, PassInfoWithRun) {
EXPECT_TRUE(fiu_fail("fail"));
EXPECT_EQ(fault_injection_last_info(), "test");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does "test" come from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here:

add_aktualizr_test(NAME fiuinfo SOURCES fiuinfo_test.cc NO_VALGRIND LAUNCH_CMD ${PROJECT_SOURCE_DIR}/scripts/fiu run -c "enable name=fail,failinfo=test" -- ARGS ${PROJECT_SOURCE_DIR}/scripts/fiu)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. It could perhaps be a more greppable string, but not a big deal at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, changed it to something more unique

lbonn added 6 commits March 21, 2019 17:28
The new constraints are: primary first and `loadEcuSerials` returns the
same order as given in the `storeEcuSerials` vector parameter.

Signed-off-by: Laurent Bonnans <[email protected]>
Put the string result inside quotes, so that it can contain `:`.

Useful when the device code reflects the ECUs

Signed-off-by: Laurent Bonnans <[email protected]>
+ some refactor

Signed-off-by: Laurent Bonnans <[email protected]>
libfiu only supports sending long unsigned, so work around it by storing
strings in a binary file

Signed-off-by: Laurent Bonnans <[email protected]>
Path is passed through FIU_INFO_FILE, id has the 31th bit set to 1

Signed-off-by: Laurent Bonnans <[email protected]>
@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch from a51704b to 8f9ac73 Compare March 21, 2019 16:38
lbonn added 4 commits March 21, 2019 17:40
Proxy script for fiu-run and fiu-ctrl (`fiu run`, `fiu ctrl`).

Syntax is the same, except that it can send strings through `failinfo=`,
via an intermediary file.

The file is temporary when passed through fiu-run, otherwise it's named
after the targets' pid.

Signed-off-by: Laurent Bonnans <[email protected]>
And not description, like before

Signed-off-by: Laurent Bonnans <[email protected]>
Signed-off-by: Laurent Bonnans <[email protected]>
@lbonn lbonn force-pushed the feat/OTA-2282/more-failure-simulation branch from 8f9ac73 to cccfa33 Compare March 21, 2019 16:40
@lbonn lbonn merged commit 572b96a into master Mar 22, 2019
@lbonn lbonn deleted the feat/OTA-2282/more-failure-simulation branch March 22, 2019 09:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants