Skip to content

RUM-5878 Add the integration tests for FeatureScope public API#2209

Merged
mariusc83 merged 2 commits into
developfrom
mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api
Aug 28, 2024
Merged

RUM-5878 Add the integration tests for FeatureScope public API#2209
mariusc83 merged 2 commits into
developfrom
mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api

Conversation

@mariusc83

@mariusc83 mariusc83 commented Aug 26, 2024

Copy link
Copy Markdown
Member

What does this PR do?

In this PR we are adding the integration tests for the FeatureScope public API. Basically we are assessing the capability of the SDK core to write and propagate an event through the pipeline up to the NetworkLayer by using a MockWebServer to intercept the payloads.

Please note as this was specified also in the TestClass the sendEvent API was not tested as this functionality was already covered in the FeatureSdkCoreTest

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83 mariusc83 self-assigned this Aug 26, 2024
@mariusc83
mariusc83 force-pushed the mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api branch from 4149d49 to 7f426c2 Compare August 27, 2024 09:15
@codecov-commenter

codecov-commenter commented Aug 27, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.04%. Comparing base (b626681) to head (809d3f0).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2209      +/-   ##
===========================================
- Coverage    70.10%   70.04%   -0.05%     
===========================================
  Files          726      726              
  Lines        27009    27001       -8     
  Branches      4528     4527       -1     
===========================================
- Hits         18932    18912      -20     
+ Misses        6823     6822       -1     
- Partials      1254     1267      +13     

see 28 files with indirect coverage changes

@mariusc83
mariusc83 force-pushed the mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api branch 2 times, most recently from d12d24b to fecd166 Compare August 27, 2024 13:12
@mariusc83
mariusc83 marked this pull request as ready for review August 27, 2024 13:51
@mariusc83
mariusc83 requested review from a team as code owners August 27, 2024 13:51
APPROXIMATE_APP_START_TIME_NS,
Offset.offset(APP_START_TIME_OFFSET_NS)
)
assertThat(appStartTimeNs).isPositive()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is still better to keep this assertion stricter. Like for sure, it should be positive, but also not exceed some reasonable value. Maybe like 5-10 seconds? WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it was very flaky but yes let's try something else.

Comment on lines +65 to +71
val eventMetadata = forge.anAlphabeticalString()
RawBatchEvent(
fakeEvent.toString().toByteArray(),
eventMetadata.toByteArray()
)
}
fakeBatchMetadata = forge.anAlphabeticalString().toByteArray()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we generate nullable type for event/batch metadata to cover more?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah let's do this to cover also this case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is still the same

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes but I specifically added a test below where I test for null value...just to make sure we are testing for both possibilities.


@After
fun tearDown() {
cleanupStorage()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
cleanupStorage()
cleanStorage()

for the naming consistency with cleanMockWebServer

import fr.xgouchet.elmyr.Forge
import fr.xgouchet.elmyr.ForgeryFactory

class RawBatchEventForgeryFactory : ForgeryFactory<RawBatchEvent> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this should be removed

@mariusc83
mariusc83 force-pushed the mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api branch from fecd166 to 809d3f0 Compare August 28, 2024 07:48
@mariusc83
mariusc83 requested review from 0xnm and ambushwork August 28, 2024 07:49
Comment on lines +65 to +71
val eventMetadata = forge.anAlphabeticalString()
RawBatchEvent(
fakeEvent.toString().toByteArray(),
eventMetadata.toByteArray()
)
}
fakeBatchMetadata = forge.anAlphabeticalString().toByteArray()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is still the same

APPROXIMATE_APP_START_TIME_NS,
Offset.offset(APP_START_TIME_OFFSET_NS)
)
assertThat(appStartTimeNs).isBetween(0, APPLICATION_START_TIME_UPPER_BOUND_NS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't we limit lower bound? like by using (APPLICATION_START_TIME_UPPER_BOUND_NS - <few seconds>).coerceAtLeast(0)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am afraid I will do it too flaky (we already have 2 different ways of computing this in the logic based on the API version) ...the intention of this test is not to assert the logic of computing the AppStartTime which mainly should happen in the unit test. I think here we should make sure that this value is relevant enough. What do you think ?

@mariusc83
mariusc83 merged commit ce70e25 into develop Aug 28, 2024
@mariusc83
mariusc83 deleted the mconstantin/rum-5878/add-integration-test-for-feature-sdk-core-api branch August 28, 2024 12:31
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.

4 participants