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

RUN integration tests on API 35 in testing pyramid #2272

Merged

Conversation

mariusc83
Copy link
Member

What does this PR do?

Updates the latest API version for running our integration tests to API 35.

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 Sep 19, 2024
@mariusc83 mariusc83 requested review from a team as code owners September 19, 2024 15:02
Copy link
Member

@0xnm 0xnm left a comment

Choose a reason for hiding this comment

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

lgtm!

as a part of API 35 support, we also need to modify target SDK, build tools version, etc. in the Gradle config and Docker file as well.

@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.98%. Comparing base (529e791) to head (85ea30a).
Report is 31 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2272   +/-   ##
========================================
  Coverage    69.98%   69.98%           
========================================
  Files          731      731           
  Lines        27204    27212    +8     
  Branches      4574     4577    +3     
========================================
+ Hits         19037    19043    +6     
+ Misses        6896     6881   -15     
- Partials      1271     1288   +17     
Files with missing lines Coverage Δ
...onreplay/internal/recorder/resources/BitmapPool.kt 87.50% <ø> (ø)
...ay/internal/recorder/resources/BitmapPoolHelper.kt 57.14% <ø> (ø)
...android/sessionreplay/internal/utils/CacheUtils.kt 11.11% <ø> (ø)

... and 30 files with indirect coverage changes

@mariusc83 mariusc83 force-pushed the mconstantin/rum-6069/run-integration-tests-on-api-35 branch from d3892b5 to e0c771b Compare September 20, 2024 12:01

internal class BitmapPoolHelper(
private val invocationUtils: InvocationUtils = InvocationUtils()
) {
internal fun generateKey(bitmap: Bitmap) =
generateKey(bitmap.width, bitmap.height, bitmap.config)
generateKey(bitmap.width, bitmap.height, bitmap.safeConfig())
Copy link
Member

Choose a reason for hiding this comment

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

So how it was working in the past? we now know, that annotation wasn't correct and Bitmap.getConfig may return null. It should crash runtime, because generateKey doesn't expect null value for the config parameter.

Also do we need safeConfig method? Maybe in some code paths we can handle null returned case without fallback value.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes...in case it will return null it will crash. I've never seen this bug reported yet so I suspect this happens quite rarely. I am not sure that this will require a hotfix. @xgouchet @jonathanmos ?

Copy link
Member Author

Choose a reason for hiding this comment

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

the reason why I introduce the safeConfig is just to be re - used also in some tests where I had to replace it and maybe for later...looks cleaner this way.

Copy link
Member

@jonathanmos jonathanmos Sep 23, 2024

Choose a reason for hiding this comment

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

The getConfig method is annotated NonNull for some reason. I haven't seen any cases of this returning null, but if it can then we do indeed need a safe method.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The question was more if we can leave it like this until the next release where the safe method will be in place. You said you did not see any issue so far so I guess this is very rare when it returns null. We could leave it like this without a hotfix.

Copy link
Member

Choose a reason for hiding this comment

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

Warning

I'm not at all convinced we need a safeCongif here as we lose the information. Any local log or telemetry that could be sent from the generated key will hide the fact that the bitmap configuration was null.
In the current case, I'd prefer to have a generateKey allowing a nullable config instead

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't see any telemetry there, in any case the Config in this case is just a variable in the key generation so with our without it null will have more or less same changes of collisions for 2 elements with Bitmap.config null so I am ok with any approach. @jonathanmos , @0xnm what do you guys think ?


// some of this memory level are not being triggered after API 34. We still need to keep them for now
// for lower versions
@Suppress("DEPRECATION")
Copy link
Member

Choose a reason for hiding this comment

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

what is the replacement then? should we use it for newer APIs?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can leave it like it is and prepare a task to remove those later. The only think that will happen for newer APIs is that those level will never be triggered. I don't see any harm now, maybe to create a task to clean these levels ?

Copy link
Member

Choose a reason for hiding this comment

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

yes, no harm. My point is just that if something is deprecated, then probably there is a replacement for the newer APIs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. no replacement suggested in their docs, I think they simply don't support these levels anymore and only kept few important ones. I think they did not need this granularity anymore.

@@ -142,7 +142,7 @@ internal class DataStoreFileReaderTest {
@Test
fun `M log error W read() { invalid number of blocks }`() {
// Given
blocksReturned.removeLast()
blocksReturned.removeAt(blocksReturned.size - 1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
blocksReturned.removeAt(blocksReturned.size - 1)
blocksReturned.removeAt(blocksReturned.lastIndex)

@@ -213,7 +213,7 @@ internal class DataStoreFileReaderTest {
@Test
fun `M return onFailure W read() { invalid number of blocks }`() {
// Given
blocksReturned.removeLast()
blocksReturned.removeAt(blocksReturned.size - 1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
blocksReturned.removeAt(blocksReturned.size - 1)
blocksReturned.removeAt(blocksReturned.lastIndex)


internal class BitmapPoolHelper(
private val invocationUtils: InvocationUtils = InvocationUtils()
) {
internal fun generateKey(bitmap: Bitmap) =
generateKey(bitmap.width, bitmap.height, bitmap.config)
generateKey(bitmap.width, bitmap.height, bitmap.safeConfig())
Copy link
Member

Choose a reason for hiding this comment

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

Warning

I'm not at all convinced we need a safeCongif here as we lose the information. Any local log or telemetry that could be sent from the generated key will hide the fact that the bitmap configuration was null.
In the current case, I'd prefer to have a generateKey allowing a nullable config instead

@mariusc83 mariusc83 force-pushed the mconstantin/rum-6069/run-integration-tests-on-api-35 branch from e0c771b to bedcb09 Compare September 23, 2024 12:31
@mariusc83 mariusc83 force-pushed the mconstantin/rum-6069/run-integration-tests-on-api-35 branch 2 times, most recently from cec0387 to 29219d7 Compare September 23, 2024 14:36
Comment on lines 19 to 23
return if (config != null) {
"$width-$height-$config"
} else {
"$width-$height-null"
}
Copy link
Member

Choose a reason for hiding this comment

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

Note

the String templating with a nullable variable will give the same result, you don't have to do this

Suggested change
return if (config != null) {
"$width-$height-$config"
} else {
"$width-$height-null"
}
return "$width-$height-$config"

Copy link
Member Author

Choose a reason for hiding this comment

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

yes just a weird autocomplete

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry this comment was for the testing assertion message but for this case I was not aware that having null value in the string format will not actually break so I preferred the safer way. In the end I like it more as it is more explicit regarding what to expect.

Comment on lines 151 to 158
testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockConfig)

// When
testedCache.put(mockBitmap)

// Then
val actualBitmap = testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockBitmap.config)
val actualBitmap =
testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Note

Why are those changes necessary ?

Copy link
Member Author

Choose a reason for hiding this comment

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

mockBitmap.config returns nullable now and that method expects nonnull so we are using directly the mockConfig with which this mockBitmap is mocked with.

Copy link
Member

Choose a reason for hiding this comment

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

Why can't we make the getBitmapByProperties() method accept a nullable Config? The only usage of the config is to call the generateKey which this PR modifies to allow a nullable config.

Copy link
Member Author

Choose a reason for hiding this comment

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

But why we should change this method if this code if this is not required ? All the methods calling this code are keeping the contract, if we would change this code we would change only for the sake of this test, this is not the same thing as the BitmapPoolHelper#generateKey method which accepts a bitmap and delegates to generateKey method. This method has a different scope and requires in the contract that the config should be NonNull when calling it. I really don't get why do you want to change this.

val key = testedHelper.generateKey(mockBitmap)

// Then
assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-${null}")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-${null}")
assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-null")

@mariusc83 mariusc83 force-pushed the mconstantin/rum-6069/run-integration-tests-on-api-35 branch from 29219d7 to 9a1cb71 Compare September 24, 2024 09:20
@mariusc83 mariusc83 force-pushed the mconstantin/rum-6069/run-integration-tests-on-api-35 branch from 9a1cb71 to 478df2e Compare September 24, 2024 09:28
@mariusc83 mariusc83 requested a review from xgouchet September 24, 2024 11:35
@mariusc83 mariusc83 merged commit 64ffa00 into develop Sep 25, 2024
23 checks passed
@mariusc83 mariusc83 deleted the mconstantin/rum-6069/run-integration-tests-on-api-35 branch September 25, 2024 15:03
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.

6 participants