-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce HighlyRateLimited tag for tests
- Loading branch information
1 parent
a543647
commit 422c06e
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.mullvad.mullvadvpn.test.e2e.annotations | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.jupiter.api.extension.ConditionEvaluationResult | ||
import org.junit.jupiter.api.extension.ExecutionCondition | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import net.mullvad.mullvadvpn.test.e2e.constant.IGNORE_HIGHLY_RATE_LIMITED | ||
import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument | ||
|
||
/** | ||
* Annotation for tests making use of API endpoints/requests that are highly rate limited such as failed login requests. | ||
*/ | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@ExtendWith(HighlyRateLimited.ShouldRunWhenSeverelyAffectedByRateLimiting::class) | ||
annotation class HighlyRateLimited { | ||
class ShouldRunWhenSeverelyAffectedByRateLimiting: ExecutionCondition { | ||
override fun evaluateExecutionCondition(context: ExtensionContext?): ConditionEvaluationResult { | ||
val ignoreHighlyRateLimited = InstrumentationRegistry.getArguments().getRequiredArgument( | ||
IGNORE_HIGHLY_RATE_LIMITED).toBoolean() | ||
|
||
if (ignoreHighlyRateLimited) { | ||
return ConditionEvaluationResult.disabled("Skipping test because this run is configured to skip tests that are highly affected by rate limiting") | ||
} else { | ||
return ConditionEvaluationResult.enabled("Running test highly affected by rate limiting") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters