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

read composite on root path #1520

Conversation

mgdlkundera
Copy link
Contributor

Integration tests for root

@sbernard31
Copy link
Contributor

(@mgdlkundera let me know when this is in a reviewable state)

@mgdlkundera
Copy link
Contributor Author

@sbernard31 It's ready for review

@@ -74,9 +78,22 @@ public void removeListener(ObjectsListener listener) {
@Override
public ReadCompositeResponse read(LwM2mServer server, ReadCompositeRequest request) {
List<LwM2mPath> paths = request.getPaths();
// TODO: add checks for failure and log it
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep I think some check should be done here.

The spec says :

The Read-Composite operation is treated as non-atomic and handled as best effort by the client. That is, if any of the requested resources do not have a valid value to return, they will not be included in the response.

(http://www.openmobilealliance.org/release/LightweightM2M/V1_1_1-20190617-A/HTML-Version/OMA-TS-LightweightM2M_Core-V1_1_1-20190617-A.html#6-3-8-0-638-Read-Composite-Operation)

So I think on failure, we should not stop the read-composite operation but just log as error.
(so error will not be seen at server side)

Comment on lines +31 to +32
default void visit(LwM2mRoot root) {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we should add a default visit.
Better to add to all visitor the new function and raise exception is not supported.

Comment on lines 46 to 47
// TODO: visitors currently don't support a visit from LwM2mRoot
visitor.visit(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure to get this TODO ?

Comment on lines 51 to 58
public String toPrettyString(LwM2mPath path) {
return null;
}

@Override
public StringBuilder appendPrettyNode(StringBuilder b, LwM2mPath path) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be implemented.

return objects;
}

// TODO: add compare and other stuff that a LwM2m node should have
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep this should probably added.

(See #1504 maybe this could help)

Comment on lines +326 to 327
if (!n.isEmpty() && !bn.equals("/")) {
bn += "/";
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds strange I need to look at this deeper.

Comment on lines +124 to +126
// verify result
// assertEquals(CONTENT, response.getCode());
// assertContentFormat(responseContentFormat, response);
Copy link
Contributor

Choose a reason for hiding this comment

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

should be removed ?

Set<Integer> objectIdsFromRootObject = root.getObjects().keySet();
Set<Integer> objectIdsFromObjectTree = new HashSet<>(Arrays.asList(1, 3, 3442));

// assertEquals(objectIdsFromObjectTree, objectIdsFromRootObject);
Copy link
Contributor

Choose a reason for hiding this comment

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

should be removed ?

@@ -53,39 +54,89 @@ public JacksonLwM2mNodeSerializer() {
@Override
public void serialize(LwM2mNode src, JsonGenerator gen, SerializerProvider provider) throws IOException {
Map<String, Object> element = new HashMap<>();
Map<String, Object> element1 = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

all modification in JacksonLwM2mNodeSerializer are about demo so It should not be part of this PR.
We will see later when/if we add a UI for this.

}

@TestAllCases
public void can_read_root_single_resource(ContentFormat requestContentFormat, ContentFormat responseContentFormat,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure to understand why there is several test where all do a ReadComposite on / ?
Maybe better to have only 1 test OR I missed something ?

A possible way to test it could be to :

  • do a ReadComposite.
  • Check that all expected object are here. (maybe using Registration.getSupportedObject() ?)
  • (optionally) on instances too (using Registration.getAvailableInstances())
  • Then for each LwM2mObject in ReadComposite response, you do a ReadRequest on this object and you check that LwM2mObject returned is equals of LwM2mObject from ReadComposite response.

(This will work if no value change between 2 call, if some change let me know)

@sbernard31
Copy link
Contributor

Not a big deal:slightly_smiling_face: but maybe you could find :

  • a better PR name
  • a better description or at least point to corresponding issue. (someone who clicks on the PR should vaguely understand what it is about)

test improvement, remove changes from JacksonLwM2mNodeSerializer, add equals and hashcode to LwM2mRoot and visit.
@sbernard31
Copy link
Contributor

(let me know once, you think the code must be reviewed again, no urgency on my side take, do not hesitate to take time to review your own code like if you review someone else code)

@mgdlkundera mgdlkundera changed the title Opl/composite on root integration tests read composite on root path Oct 12, 2023
@sbernard31
Copy link
Contributor

I will be unavailable next few days. I'll be back on Thursday November 2nd.

When I return, I plan to work on this.

@mgdlkundera
Copy link
Contributor Author

Thank you. I will be out of the office until Monday November 6nd.

What do you think about possibility of releasing M14 version containing this issue around November 23?

@sbernard31
Copy link
Contributor

sbernard31 commented Nov 2, 2023

What do you think about possibility of releasing M14 version containing this issue around November 23?

We can try, I created a dedicated issue #1531 for that.

@sbernard31 sbernard31 mentioned this pull request Nov 2, 2023
2 tasks
@mgdlkundera
Copy link
Contributor Author

I have one more question, can I add to this pull request observe for root?

@sbernard31
Copy link
Contributor

@mgdlkundera I'm working on this PR, I hope I will provide something before the end of the day. So I don't advice to work more on it for now.

About observe, I advice to start to work on it in another PR. 🙂

@sbernard31
Copy link
Contributor

sbernard31 commented Nov 7, 2023

I created a PR based on this one : #1534

I added a new Interface LwM2mChildNode because until now a LwM2mNode had a getId() method but for LwM2mRoot this is not true.

@mgdlkundera, @JaroslawLegierski let me know if you plan to review the PR. 🙏
(better to review commit by commit)

@sbernard31
Copy link
Contributor

sbernard31 commented Nov 9, 2023

@mgdlkundera, @JaroslawLegierski please let me know if you plan to review because if you don't plan to do it better to put this in master so we can have some beta tester with sandbox users.

@JaroslawLegierski
Copy link
Contributor

@mgdlkundera, @JaroslawLegierski please let me know if you plan to review because if you don't plan to do it better to put this in master so we can have some beta tester with sandbox users.

If it is urgent then I suggest integrating it with the master (I can review it on Tuesday next week at the earliest).

@sbernard31
Copy link
Contributor

If it is urgent then I suggest integrating it with the master (I can review it on Tuesday next week at the earliest).

On my side there is no urgency.
But If we want to target 23 November for 2.0.0-M14(#1531), I think it makes sense to put it in master as soon as possible to see possible regression from sandbox users.

Looking at : zephyrproject-rtos/zephyr#64013
I think I will try to add at least REST API support to leshan-server-demo, so zephyr could test this news feature.

@sbernard31
Copy link
Contributor

@JaroslawLegierski , @mgdlkundera,

As planned, I integrated #1534 in master
So we will get maybe get some users sandboxes feedback (or at least detect possible regression)
But this is still possible to you to review the code, if there is something not good we can still fix/adapt it in another PR.

Note that I also added support in leshan-server-demo.

Thx both of you for you work/help on this 🙏 !

@sbernard31 sbernard31 closed this Nov 10, 2023
@mgdlkundera
Copy link
Contributor Author

I prepare implementation of observe for root, here is a link:
master...JaroslawLegierski:leshan:opl/observe_for_root

Can I create new pull request from this branch?

@sbernard31
Copy link
Contributor

Yep.
Please could you provide code much more similar to Read-Composite and could you also add integration tests.

@mgdlkundera
Copy link
Contributor Author

I improved code and add test. Here is pull request:
#1539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants