-
Notifications
You must be signed in to change notification settings - Fork 56
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
Bypass duplicate message filtering on mapper startup with config flag #2632
Conversation
f6e938d
to
787de72
Compare
Robot Results
|
787de72
to
39d0d9f
Compare
39d0d9f
to
d9ff78a
Compare
crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs
Outdated
Show resolved
Hide resolved
@@ -68,15 +68,22 @@ pub struct MessageLogWriter { | |||
} | |||
|
|||
impl MessageLogWriter { | |||
pub fn new<P>(log_dir: P) -> Result<MessageLogWriter, std::io::Error> | |||
pub fn new<P>(log_dir: P, sync_on_startup: bool) -> Result<MessageLogWriter, std::io::Error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn new<P>(log_dir: P, sync_on_startup: bool) -> Result<MessageLogWriter, std::io::Error> | |
pub fn new<P>(log_dir: P, truncate: bool) -> Result<MessageLogWriter, std::io::Error> |
From the MessageLogWriter
, there is no notion of sync. The argument just decides whether to start fresh or append to the existing.
d9ff78a
to
8890ca0
Compare
36bda79
to
e8a5144
Compare
Codecov ReportAttention:
Additional details and impacted files
|
e8a5144
to
352c3cb
Compare
352c3cb
to
9229f94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working as expected. However, the code can be a bit simpler.
crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs
Outdated
Show resolved
Hide resolved
log_dir: P, | ||
clean_start: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing a log_dir
and clean_start
flag telling to truncate or not the log.
I would consider to pass only a MessageLogWriter
, built from the log using MessageLogWriter::new(log_dir)
or MessageLogWriter::new_truncated(log_dir)
:
log_dir: P, | |
clean_start: bool, | |
message_log: MessageLogWriter, |
For that to work the MessageLogWriter
has to be improved to build a MessageLogReader
on the same log dir. So the entity store can use its self.message_log
for reads and writes.
It might be better to address this only a follow-up PR after the 1.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion is to have a MessageLog
abstraction, which is passed to the entity store, out of which the MessageLogWriter
and MessageLogReader
instances can be retrieved.
9229f94
to
c83d5a6
Compare
@@ -193,13 +198,55 @@ Entities persisted and restored | |||
Should Have MQTT Messages c8y/s/us/plc2 message_contains=102 date_from=${timestamp} minimum=0 maximum=0 | |||
END | |||
|
|||
Entities send to cloud on restart | |||
Execute Command tedge mqtt pub --retain 'te/factory/shop/plc1/' '{"@type":"child-device","@id":"plc1"}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you align the @id
values used in this test along the lines of #2657 ?
|
||
*** Keywords *** | ||
|
||
Re-enable Auto-registration | ||
Execute Command sudo tedge config unset c8y.entity_store.auto_register | ||
Restart Service tedge-mapper-c8y | ||
|
||
Re-enable Clean start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-enable Clean start | |
Enable clean start |
Just to make things clearer, it'd be better to explicitly do tedge config set c8y.entity_store.clean_start true
, as the unset might be confusing to a reader who's not familiar with the default value.
Execute Command cat /etc/tedge/.tedge-mapper-c8y/entity_store.jsonl | ||
${original_last_modified_time}= Execute Command date -r /etc/tedge/.tedge-mapper-c8y/entity_store.jsonl | ||
|
||
FOR ${counter} IN RANGE 0 5 | ||
${timestamp}= Get Unix Timestamp | ||
Restart Service tedge-mapper-c8y | ||
Service Health Status Should Be Up tedge-mapper-c8y | ||
|
||
# Assert that the file contents changed on restart | ||
${last_modified_time}= Execute Command date -r /etc/tedge/.tedge-mapper-c8y/entity_store.jsonl | ||
Should Not Be Equal ${last_modified_time} ${original_last_modified_time} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the timestamp assertion is already done in the previous test, we can either skip this whole block or at least avoid the looping and limit the check to only once.
Should Have MQTT Messages c8y/s/us/plc1 message_contains=102 date_from=${timestamp} minimum=1 maximum=1 | ||
Should Have MQTT Messages c8y/s/us/plc2 message_contains=102 date_from=${timestamp} minimum=1 maximum=1 | ||
|
||
Sleep 2s reason=Make sure that previous iteration was sent to cloud |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this sleep required? That too at the end of this test. The reason isn't clear from the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that sometimes tests just fail because of that test case:
Should Have MQTT Messages c8y/s/us message_contains=101,${prefix}plc date_from=${timestamp} minimum=2 maximum=2
. It returns more messages than expected (It can be noticed for example in this run). The only solution I found to this was adding this sleep, but maybe someone else has better solution to that.
c83d5a6
to
89a5408
Compare
89a5408
to
37e0e74
Compare
57c4198
to
e4b0f60
Compare
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
e4b0f60
to
a1c8bda
Compare
Proposed changes
TODO:
sync_on_startup
with better nameTypes of changes
Paste Link to the issue
#2605
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments