oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

Fixes part of #5345 : Implement debug Controller and module for PlatformParameterController.

Open theayushyadav11 opened this issue 6 months ago • 15 comments

Fixes part of #5345

  • Introduced Ephemeral Protos.
  • Introduced Debug Module.
  • Introduced DebugController.
  • Introduced DebugImp of PlatformParameterController.

This pull request introduces a debug implementation for managing platform parameters and feature flags, along with updates to various build and dependency configurations. The most significant changes revolve around the addition of a new debug controller and module for platform parameters, as well as updates to Bazel build files to integrate these changes.

Platform Parameter Debug Implementation:

  • Added PlatformParameterControllerDebugImpl to provide debug-specific functionality for managing platform parameters and feature flags (PlatformParameterControllerDebugImpl.kt).
  • Introduced PlatformParameterControllerDebugModule to provide Dagger bindings for the debug implementation (PlatformParameterControllerDebugModule.kt).
  • Added PlatformParameterDebugController interface to define debug-only methods for platform parameter and feature flag management (PlatformParameterDebugController.kt).

These updates enhance the platform parameter system by introducing a debug-specific implementation, improving configurability and testability while maintaining compatibility with production modules.

Essential Checklist

  • [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • [x] Any changes to scripts/assets files have their rationale included in the PR explanation.
  • [x] The PR follows the style guide.
  • [x] The PR does not contain any unnecessary code changes from Android Studio (reference).
  • [x] The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • [ ] The PR is assigned to the appropriate reviewers (reference).

theayushyadav11 avatar Jun 07 '25 09:06 theayushyadav11

PTAL @Rd4dev .

theayushyadav11 avatar Jun 07 '25 11:06 theayushyadav11

Coverage Report

Results

Number of files assessed: 14 Overall Coverage: 38.24% Coverage Analysis: FAIL :x:

Failure Cases

File Failure Reason Status
PlatformParameterControllerDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugModule.kt
No appropriate test file found for domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugModule.kt. :x:
PlatformParameterDebugController.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugController.kt
No appropriate test file found for domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugController.kt. :x:
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
No appropriate test file found for domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt. :x:
PlatformParameterControllerProdModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerProdModule.kt
No appropriate test file found for domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerProdModule.kt. :x:

Passing coverage

Files with passing code coverage
File Coverage Lines Hit Status Min Required
InitializeDefaultLocaleRule.kttesting/src/main/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRule.kt
38.24% 39 / 102 :white_check_mark: 38% *

* represents tests with custom overridden pass/fail coverage thresholds

Exempted coverage

Files exempted from coverage
File Exemption Reason
PlatformParameterModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterSyncUpWorker.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ImageRegionSelectionInteractionView.ktapp/src/main/java/org/oppia/android/app/player/state/ImageRegionSelectionInteractionView.kt
This file is incompatible with code coverage tooling; skipping coverage check.
AlphaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
ActivityRouterModule.ktapp/src/main/java/org/oppia/android/app/activity/route/ActivityRouterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
TestApplicationComponent.ktinstrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 07 '25 17:06 github-actions[bot]

Thanks @theayushyadav11! -- as we discussed yesterday, I’ll take a review pass once the PR is fully complete — feel free to tag us if you need clarification on anything in the meantime.

Rd4dev avatar Jun 08 '25 08:06 Rd4dev

@theayushyadav11, please assign @subhajitxyz for a first review pass then @Rd4dev for a second pass.

adhiamboperes avatar Jun 09 '25 09:06 adhiamboperes

Coverage Report

Results

Number of files assessed: 8 Overall Coverage: 38.24% Coverage Analysis: PASS :white_check_mark:

Passing coverage

Files with passing code coverage
File Coverage Lines Hit Status Min Required
InitializeDefaultLocaleRule.kttesting/src/main/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRule.kt
38.24% 39 / 102 :white_check_mark: 38% *

* represents tests with custom overridden pass/fail coverage thresholds

Exempted coverage

Files exempted from coverage
File Exemption Reason
ImageRegionSelectionInteractionView.ktapp/src/main/java/org/oppia/android/app/player/state/ImageRegionSelectionInteractionView.kt
This file is incompatible with code coverage tooling; skipping coverage check.
AlphaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
ActivityRouterModule.ktapp/src/main/java/org/oppia/android/app/activity/route/ActivityRouterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
TestApplicationComponent.ktinstrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 09 '25 18:06 github-actions[bot]

Hi @Rd4dev , I have added testcases for the default values PTAL.

theayushyadav11 avatar Jun 11 '25 18:06 theayushyadav11

Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks!

oppiabot[bot] avatar Jun 11 '25 18:06 oppiabot[bot]

Coverage Report

Results

Number of files assessed: 8 Overall Coverage: 38.24% Coverage Analysis: PASS :white_check_mark:

Passing coverage

Files with passing code coverage
File Coverage Lines Hit Status Min Required
InitializeDefaultLocaleRule.kttesting/src/main/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRule.kt
38.24% 39 / 102 :white_check_mark: 38% *

* represents tests with custom overridden pass/fail coverage thresholds

Exempted coverage

Files exempted from coverage
File Exemption Reason
TestApplicationComponent.ktinstrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
AlphaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
ImageRegionSelectionInteractionView.ktapp/src/main/java/org/oppia/android/app/player/state/ImageRegionSelectionInteractionView.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ActivityRouterModule.ktapp/src/main/java/org/oppia/android/app/activity/route/ActivityRouterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 11 '25 19:06 github-actions[bot]

@theayushyadav11 -- I think with the details Ben shared in the Android CLaM chat today, you should now be fully unblocked for testing the remote DB values. Please go ahead and complete the test suite, fix any CI issues

@theayushyadav11, please assign @subhajitxyz for a first review pass then @Rd4dev for a second pass.

and as mentioned earlier — assign Subhajit for the initial pass.

Rd4dev avatar Jun 12 '25 02:06 Rd4dev

@theayushyadav11 -- Also, as mentioned in the last meeting, per the linked comment, it was suggested to create a duplicate module for the debug variant instead of extracting the controller. This was also suggested to align with the ongoing efforts of updating test modules across the codebase.

Could you also update the PR to reflect this approach as well?

And a quick reminder to update to the latest develop and update the PR description before assigning it for review.

Rd4dev avatar Jun 12 '25 20:06 Rd4dev

Hi @subhajitxyz PTAL.

theayushyadav11 avatar Jun 13 '25 17:06 theayushyadav11

Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks!

oppiabot[bot] avatar Jun 13 '25 17:06 oppiabot[bot]

Coverage Report

Results

Number of files assessed: 8 Overall Coverage: 0.00% Coverage Analysis: PASS :white_check_mark:

Exempted coverage

Files exempted from coverage
File Exemption Reason
TestApplicationComponent.ktinstrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterDebugController.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugController.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterControllerDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugModule.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 13 '25 19:06 github-actions[bot]

Thanks @theayushyadav11 , I took an initial pass and added some minor comments. Overall, it looks good to me.

subhajitxyz avatar Jun 14 '25 07:06 subhajitxyz

Coverage Report

Results

Number of files assessed: 7 Overall Coverage: 0.00% Coverage Analysis: PASS :white_check_mark:

Exempted coverage

Files exempted from coverage
File Exemption Reason
TestApplicationComponent.ktinstrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugModule.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterDebugController.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugController.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 17 '25 12:06 github-actions[bot]

@Rd4dev PTAL.

theayushyadav11 avatar Jun 22 '25 21:06 theayushyadav11

Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks!

oppiabot[bot] avatar Jun 22 '25 21:06 oppiabot[bot]

Coverage Report

Results

Number of files assessed: 9 Overall Coverage: 0.00% Coverage Analysis: PASS :white_check_mark:

Exempted coverage

Files exempted from coverage
File Exemption Reason
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
StateFragment.ktapp/src/main/java/org/oppia/android/app/player/state/StateFragment.kt
This file is incompatible with code coverage tooling; skipping coverage check.
StateDeck.ktdomain/src/main/java/org/oppia/android/domain/state/StateDeck.kt
This file is exempted from having a test file; skipping coverage check.
ExplorationProgressController.ktdomain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugModule.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterDebugController.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugController.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 23 '25 14:06 github-actions[bot]

@theayushyadav11 -- Assigning this back to you to proceed with the debugImpl approach you discussed with the team during the last meeting.

Rd4dev avatar Jun 25 '25 03:06 Rd4dev

Coverage Report

Results

Number of files assessed: 5 Overall Coverage: 0.00% Coverage Analysis: PASS :white_check_mark:

Exempted coverage

Files exempted from coverage
File Exemption Reason
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugModule.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 25 '25 16:06 github-actions[bot]

PTAL @Rd4dev .

theayushyadav11 avatar Jun 27 '25 00:06 theayushyadav11

Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks!

oppiabot[bot] avatar Jun 27 '25 00:06 oppiabot[bot]

Coverage Report

Results

Number of files assessed: 6 Overall Coverage: 0.00% Coverage Analysis: PASS :white_check_mark:

Exempted coverage

Files exempted from coverage
File Exemption Reason
GaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/ga/GaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
BetaApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
DeveloperApplicationComponent.ktapp/src/main/java/org/oppia/android/app/application/dev/DeveloperApplicationComponent.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterDebugModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterDebugModule.kt
This file is exempted from having a test file; skipping coverage check.
PlatformParameterControllerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterControllerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.
PlatformParameterModule.ktdomain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

github-actions[bot] avatar Jun 27 '25 00:06 github-actions[bot]

Unassigning @Rd4dev since the review is done.

oppiabot[bot] avatar Jun 29 '25 19:06 oppiabot[bot]

Hi @theayushyadav11, it looks like some changes were requested on this pull request by @Rd4dev. PTAL. Thanks!

oppiabot[bot] avatar Jun 29 '25 19:06 oppiabot[bot]

PTAL @Rd4dev , I have addressed the comments and made changes as requested.

theayushyadav11 avatar Jun 29 '25 20:06 theayushyadav11

Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks!

oppiabot[bot] avatar Jun 29 '25 20:06 oppiabot[bot]

@theayushyadav11 -- Looks like CI is failing—please address it and reassign. Also, ensure new changes align with earlier feedback.

Rd4dev avatar Jun 30 '25 06:06 Rd4dev

9

@theayushyadav11 -- Looks like CI is failing—please address it and reassign. Also, ensure new changes align with earlier feedback.

Hi @Rd4dev I have written the test but it is returning false , I think there is again some issue with the module setup can you please go through it.(Test)

theayushyadav11 avatar Jun 30 '25 07:06 theayushyadav11

Hi @Rd4dev I have written the test but it is returning false , I think there is again some issue with the module setup can you please go through it.(Test)

It seems the issue [CI StackTrace] originates from how PlatformParameterController is being provided. The current setup in TestPlatformParameterModule binds it to the ProdImpl, which leads to using the production implementation to load parameters. This means the debug implementation’s load states are never loaded in the tests, and its internal flags (like initialization status) remain unset or default to false.

There was 1 failure:
1) testGetParameterInitializationStatus_initialState_isTrue
expected to be true

To address this, we should skip the controller provision from TestPlatformParameterModule and define a debug-specific controller provision in TestModule, ensuring that the debug implementation is explicitly used in our tests.

@Module
class TestModule {
  @Provides
  @Singleton
  fun providesPlatformParameterController(
    impl: PlatformParameterControllerDebugImpl
  ): PlatformParameterController = impl
}

Similarly, other dependencies like PlatformParameterProcessState and PlatformParameterConfigRetriever are also required for DebugImpl to function as expected. Since the production version (ProdImpl) uses factory-based construction, those provisions from TestPlatformParameterModule might not align correctly. So we should define them directly in TestModule, tailored for DebugImpl.

Rd4dev avatar Jun 30 '25 08:06 Rd4dev