-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e session/error empty/partial scenarios to buildkite fixture
- Loading branch information
1 parent
75cb644
commit de0b66f
Showing
8 changed files
with
286 additions
and
79 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Feature: Cached Session Reports | ||
|
||
Scenario: If an empty file is in the cache directory then zero requests should be made | ||
When I run "EmptySessionScenario" and relaunch the app | ||
And I configure the app to run in the "non-crashy" state | ||
And I run "EmptySessionScenario" | ||
Then I should receive no requests | ||
|
||
Scenario: Sending internal error reports on API <26 | ||
When I run "PartialSessionScenario" and relaunch the app | ||
And I configure the app to run in the "non-crashy" state | ||
And I run "PartialSessionScenario" | ||
Then I should receive no requests | ||
|
||
Scenario: If a file in the cache directory is deleted before a request completes, zero further requests should be made | ||
When I run "DeletedSessionScenario" and relaunch the app | ||
And I configure the app to run in the "non-crashy" state | ||
And I run "DeletedSessionScenario" | ||
Then I should receive no requests |
58 changes: 58 additions & 0 deletions
58
...azerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/DeletedReportScenario.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,58 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.os.storage.StorageManager | ||
import android.util.Log | ||
|
||
import com.bugsnag.android.* | ||
import com.bugsnag.android.Configuration | ||
import java.io.File | ||
|
||
internal class DeletedReportScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
init { | ||
config.setAutoCaptureSessions(false) | ||
|
||
if (context is Activity) { | ||
eventMetaData = context.intent.getStringExtra("eventMetaData") | ||
|
||
if (eventMetaData != "non-crashy") { | ||
disableAllDelivery(config) | ||
} else { | ||
val ctor = Class.forName("com.bugsnag.android.DefaultDelivery").declaredConstructors[0] | ||
ctor.isAccessible = true | ||
val baseDelivery = ctor.newInstance(null) as Delivery | ||
val errDir = File(context.cacheDir, "bugsnag-errors") | ||
|
||
config.delivery = object: Delivery { | ||
override fun deliver(payload: SessionTrackingPayload, config: Configuration) { | ||
baseDelivery.deliver(payload, config) | ||
} | ||
|
||
override fun deliver(report: Report, config: Configuration) { | ||
// delete files before they can be delivered | ||
val files = errDir.listFiles() | ||
files.forEach { | ||
Log.d("Bugsnag", "Deleting file: ${it.delete()}") | ||
} | ||
|
||
Log.d("Bugsnag", "Files available " + errDir.listFiles()[0].exists()) | ||
baseDelivery.deliver(report, config) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
|
||
if (eventMetaData != "non-crashy") { | ||
Bugsnag.notify(java.lang.RuntimeException("Whoops")) | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...zerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/DeletedSessionScenario.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,67 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.os.Handler | ||
import android.os.HandlerThread | ||
import android.os.storage.StorageManager | ||
import android.util.Log | ||
|
||
import com.bugsnag.android.* | ||
import com.bugsnag.android.Configuration | ||
import java.io.File | ||
|
||
internal class DeletedSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
init { | ||
config.setAutoCaptureSessions(false) | ||
|
||
if (context is Activity) { | ||
eventMetaData = context.intent.getStringExtra("eventMetaData") | ||
|
||
if (eventMetaData != "non-crashy") { | ||
disableAllDelivery(config) | ||
} else { | ||
val ctor = Class.forName("com.bugsnag.android.DefaultDelivery").declaredConstructors[0] | ||
ctor.isAccessible = true | ||
val baseDelivery = ctor.newInstance(null) as Delivery | ||
val errDir = File(context.cacheDir, "bugsnag-sessions") | ||
|
||
config.delivery = object: Delivery { | ||
override fun deliver(payload: SessionTrackingPayload, config: Configuration) { | ||
// delete files before they can be delivered | ||
val files = errDir.listFiles() | ||
files.forEach { | ||
Log.d("Bugsnag", "Deleting file: ${it.delete()}") | ||
} | ||
|
||
Log.d("Bugsnag", "Files available " + errDir.listFiles()[0].exists()) | ||
baseDelivery.deliver(payload, config) | ||
} | ||
|
||
override fun deliver(report: Report, config: Configuration) { | ||
baseDelivery.deliver(report, config) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
|
||
if (eventMetaData != "non-crashy") { | ||
Bugsnag.startSession() | ||
} | ||
|
||
val thread = HandlerThread("HandlerThread") | ||
thread.start() | ||
|
||
Handler(thread.looper).post { | ||
flushAllSessions() | ||
} | ||
} | ||
} |
31 changes: 25 additions & 6 deletions
31
.../mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/EmptyReportScenario.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 |
---|---|---|
@@ -1,21 +1,40 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.os.storage.StorageManager | ||
|
||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import java.io.File | ||
|
||
/** | ||
* Verifies that if a report is empty and a beforeSend callback is set, | ||
* minimal information is still sent to bugsnag. | ||
*/ | ||
internal class EmptyReportScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
init { | ||
config.setAutoCaptureSessions(false) | ||
config.beforeSend { true } | ||
val files = File(context.cacheDir, "bugsnag-errors").listFiles() | ||
files.forEach { it.writeText("") } | ||
|
||
if (context is Activity) { | ||
eventMetaData = context.intent.getStringExtra("eventMetaData") | ||
val errDir = File(context.cacheDir, "bugsnag-errors") | ||
|
||
if (eventMetaData != "non-crashy") { | ||
disableAllDelivery(config) | ||
} else { | ||
val files = errDir.listFiles() | ||
files.forEach { it.writeText("") } | ||
} | ||
} | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
|
||
if (eventMetaData != "non-crashy") { | ||
Bugsnag.notify(java.lang.RuntimeException("Whoops")) | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...mazerunner/src/main/java/com/bugsnag/android/mazerunner/scenarios/EmptySessionScenario.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,51 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.os.Handler | ||
import android.os.HandlerThread | ||
import android.os.storage.StorageManager | ||
import android.util.Log | ||
|
||
import com.bugsnag.android.* | ||
import com.bugsnag.android.Configuration | ||
import java.io.File | ||
|
||
internal class EmptySessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
init { | ||
config.setAutoCaptureSessions(false) | ||
config.beforeSend { true } | ||
|
||
if (context is Activity) { | ||
eventMetaData = context.intent.getStringExtra("eventMetaData") | ||
val dir = File(context.cacheDir, "bugsnag-sessions") | ||
|
||
if (eventMetaData != "non-crashy") { | ||
disableAllDelivery(config) | ||
} else { | ||
val files = dir.listFiles() | ||
Log.d("Bugsnag", "Empty sessions: ${files}") | ||
files.forEach { it.writeText("") } | ||
} | ||
} | ||
} | ||
|
||
override fun run() { | ||
super.run() | ||
|
||
if (eventMetaData != "non-crashy") { | ||
Bugsnag.startSession() | ||
} | ||
|
||
val thread = HandlerThread("HandlerThread") | ||
thread.start() | ||
|
||
Handler(thread.looper).post { | ||
flushAllSessions() | ||
} | ||
} | ||
} |
Oops, something went wrong.