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

Wait for session scenarios to send session before crashing #435

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bugsnag.android.mazerunner.scenarios;

import android.content.Context;
import android.os.Handler;

import com.bugsnag.android.Bugsnag;
import com.bugsnag.android.Configuration;
Expand All @@ -14,6 +15,8 @@ public class CXXStartSessionScenario extends Scenario {
System.loadLibrary("entrypoint");
}

private Handler handler = new Handler();

public native int crash(int counter);

public CXXStartSessionScenario(@NonNull Configuration config, @NonNull Context context) {
Expand All @@ -28,7 +31,13 @@ public void run() {

if (metadata == null || !metadata.equals("non-crashy")) {
Bugsnag.getClient().startSession();
crash(0);

handler.postDelayed(new Runnable() {
@Override
public void run() {
crash(0);
}
}, 8000);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bugsnag.android.mazerunner.scenarios;

import android.content.Context;
import android.os.Handler;

import com.bugsnag.android.Bugsnag;
import com.bugsnag.android.Configuration;
Expand All @@ -14,6 +15,8 @@ public class CXXStopSessionScenario extends Scenario {
System.loadLibrary("entrypoint");
}

private Handler handler = new Handler();

public native int crash(int counter);

public CXXStopSessionScenario(@NonNull Configuration config, @NonNull Context context) {
Expand All @@ -29,7 +32,13 @@ public void run() {
if (metadata == null || !metadata.equals("non-crashy")) {
Bugsnag.getClient().startSession();
Bugsnag.getClient().stopSession();
crash(0);

handler.postDelayed(new Runnable() {
@Override
public void run() {
crash(0);
}
}, 8000);
}
}
}
4 changes: 4 additions & 0 deletions features/native_session_tracking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Feature: NDK Session Tracking

Scenario: Stopped session is not in payload of unhandled NDK error
When I run "CXXStopSessionScenario"
And I wait a bit
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do, and why do we required two of them? Is it possible to detect if an app is running through CLI somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This step will wait for a set amount of time that is lower locally, but increased on CI. I believe it requires 2 as that's what was used in previous scenarios involving sessions and native errors.

wait_time = ENV['MAZE_WAIT_TIME'] || (RUNNING_CI ? '20' : '5')

I believe it might be possible to detect if an app is running through adb but we don't currently have that setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it relied on somewhere else as well, or could we just bump the time up in a single step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the timing is relied on in other places.

And I wait a bit
And I configure the app to run in the "non-crashy" state
And I relaunch the app
Then I should receive 2 requests
Expand All @@ -11,6 +13,8 @@ Scenario: Stopped session is not in payload of unhandled NDK error

Scenario: Started session is in payload of unhandled NDK error
When I run "CXXStartSessionScenario"
And I wait a bit
And I wait a bit
And I configure the app to run in the "non-crashy" state
And I relaunch the app
Then I should receive 2 requests
Expand Down