Skip to content

Conversation

aanorbel
Copy link
Member

@aanorbel aanorbel commented Nov 18, 2024

Closes #173, #174

Known issues

  • Experimental description

@aanorbel aanorbel marked this pull request as draft November 18, 2024 12:45
@aanorbel aanorbel requested a review from sdsantos December 3, 2024 10:51
@aanorbel aanorbel marked this pull request as ready for review December 3, 2024 10:51
Copy link
Contributor

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

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

I feel we should remove Defaults descriptors all together. If we don't have them anymore, we don't need the extra complexity. That means:

  • No need to keep both Descriptor and InstalledTestDescriptorModel classes
  • Descriptor.Source is not needed
  • DefaultTestDescriptor is not needed
  • GetDefaultTestDescriptors is not needed
  • Only isDefault() method is needed, the isInstalledNonDefaultDescriptor() should just be !isDefault().

That should simplify a lot of the existing code.


val isDefaultTestDescriptor get() = id.value in 10470..10474 // TODO(aanorbel): switch to OONI reserved namespace

val key get() = if (isDefaultTestDescriptor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more like a settings key now no? Just to make it clear why we still need this. Because for all other purposes now we can use the ID.

@sdsantos
Copy link
Contributor

sdsantos commented Dec 3, 2024

I feel we should remove Defaults descriptors all together. If we don't have them anymore, we don't need the extra complexity. That means:

  • No need to keep both Descriptor and InstalledTestDescriptorModel classes
  • Descriptor.Source is not needed
  • DefaultTestDescriptor is not needed
  • GetDefaultTestDescriptors is not needed
  • Only isDefault() method is needed, the isInstalledNonDefaultDescriptor() should just be !isDefault().

That should simplify a lot of the existing code.

Maybe we can keep both Descriptor and InstalledTestDescriptorModel. It may be useful for the updateStatus for example. But there's no need to duplicate fields, we can just have the installed model as a field of the descriptor.

@aanorbel aanorbel requested a review from sdsantos December 4, 2024 07:22
Copy link
Contributor

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

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

I found a bug. When you just have the OONI descriptors, and no custom descriptor installed, the pull-to-refresh on the Dashboard screen doesn't seem to work. The refresh icon just says at the top without animation.

}
}
companion object {
fun fromDescriptor(descriptor: Descriptor) = descriptor.source.id
Copy link
Contributor

Choose a reason for hiding this comment

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

This companion object isn't needed, it should return an object of the type Test, or it should be called something like sourceFromDescriptor. It's weird that a static factory method only returns a specific field inside its class.

@Serializable
data class Test(
val source: Source,
val source: InstalledTestDescriptorModel.Id? = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this sourceId or descriptorId to avoid confusion?

Copy link
Contributor

Choose a reason for hiding this comment

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

And this should never be null right?

RunSpecification.Full(
tests = listOf(
RunSpecification.Test(
source = RunSpecification.Test.Source.Default("websites"),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should fetch it from the DB, or hardcode the websites descriptor ID somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have OoniTests.Websites.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this is empty, it can be removed no?

@aanorbel aanorbel requested a review from sdsantos December 4, 2024 12:14

val isExpired get() = expirationDate != null && expirationDate < LocalDateTime.now()

val isDefaultTestDescriptor get() = id.value in 10470..10474 // TODO(aanorbel): switch to OONI reserved namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also check if they are in OoniTest now.

@aanorbel
Copy link
Member Author

aanorbel commented Dec 9, 2024

This will be done eventually but converting to draft for now. https://openobservatory.slack.com/archives/GKGRFHXT7/p1733782481912289?thread_ts=1733329764.355889&cid=GKGRFHXT7

@aanorbel aanorbel marked this pull request as draft December 9, 2024 22:24
@sdsantos sdsantos closed this Mar 5, 2025
@sdsantos sdsantos deleted the issues/174 branch March 5, 2025 12:57
@sdsantos sdsantos restored the issues/174 branch March 5, 2025 12:57
@sdsantos sdsantos reopened this Mar 5, 2025
@aanorbel aanorbel requested a review from sdsantos September 29, 2025 08:58
@aanorbel aanorbel marked this pull request as ready for review September 29, 2025 08:58
Copy link
Contributor

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

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

We should also migrate the ResultModel to stop having descriptorName and descriptorKey, and just have descriptorKey. That will simplify the SQL queries we have that filter by descriptor.

val netTests: List<NetTest>,
val longRunningTests: List<NetTest> = emptyList(),
val source: Source,
val source: InstalledTestDescriptorModel,
Copy link
Contributor

Choose a reason for hiding this comment

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

I had mentioned this before, but keeping both the Descriptor and the InstalledTestDescriptorModel is just a big duplication of fields now. If we are to keep both because it helps with UpdateStatus, then we should remove the duplication:

  • The Descriptor class should just have the source and UpdateStatus
  • Optionally, InstalledTestDescriptorModel could be renamed to Descriptor and Descriptor could become a DescriptorItem or DescriptorWithUpdateStatus

Comment on lines +35 to +39
WEBSITES(10470L, "websites"),
INSTANT_MESSAGING(10471L, "instant_messaging"),
CIRCUMVENTION(10472L, "circumvention"),
PERFORMANCE(10473L, "performance"),
EXPERIMENTAL(10474L, "experimental"),
Copy link
Contributor

Choose a reason for hiding this comment

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

We're using regular capitalization for enum and sealed classes in this project: WEBSITES -> Websites.


fun fromId(id: Long) = map[id]

fun isValidId(id: Long): Boolean = entries.any { it.id == id }
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're already caching the entries as a map, this could be fromId(id) != null.

import org.ooni.probe.shared.stringMonthArrayResource
import org.ooni.probe.shared.toEpoch

enum class OoniTest(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in a separate file, there's no need to be here.

val revision: Long,
)

val isDefaultTestDescriptor get() = OoniTest.isValidId(id.value.toLongOrNull() ?: -1L)
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 if we should keep with the default concept or not. It's confusing with the NewsMediaScan descriptors, which are default, but not OONI tests. Maybe split this between isOoniDescriptor and isUninstallable.

RunSpecification.Full(
tests = listOf(
RunSpecification.Test(
source = RunSpecification.Test.Source.Default("websites"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have OoniTests.Websites.

import kotlin.coroutines.CoroutineContext

class GetBootstrapTestDescriptors(
private val readAssetFile: (String) -> String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not from the PR, but this is not needed.

val descriptor = state.value.descriptor ?: return@onEach
if (descriptor.source !is Descriptor.Source.Installed) return@onEach
setAutoUpdate(descriptor.source.value.id, it.value)
if (descriptor.source == null) return@onEach
Copy link
Contributor

Choose a reason for hiding this comment

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

Source can never be null.

else -> ToggleableState.Indeterminate
}
val isRefreshEnabled get() = descriptor?.source is Descriptor.Source.Installed
val isRefreshEnabled get() = descriptor?.source != null
Copy link
Contributor

Choose a reason for hiding this comment

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

Now it's always enabled as soon as descriptor != null no?

runTest {
val descriptor = DescriptorFactory.buildDescriptorWithInstalled()
val installedDescriptor = (descriptor.source as Descriptor.Source.Installed).value
val installedDescriptor = descriptor.source!!
Copy link
Contributor

Choose a reason for hiding this comment

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

!! not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create descriptors for ooni tests.

3 participants