diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2f856184..91cdb616 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -4,3 +4,36 @@ steps: plugins: - docker-compose#v3.7.0: run: license-audit + + - label: ':docker: Assemble project' + key: 'java-jvm-build' + timeout_in_minutes: 30 + plugins: + - docker-compose#v3.7.0: + run: java-common + command: './gradlew :bugsnag:assemble :bugsnag-spring:assemble' + + - label: ':docker: Run JVM tests' + key: 'java-jvm-tests' + timeout_in_minutes: 30 + plugins: + - docker-compose#v3.7.0: + run: java-common + command: './gradlew check test' + + - label: ':docker: Mazerunner tests batch 1' + key: 'java-mazerunner-tests-1' + timeout_in_minutes: 30 + plugins: + - docker-compose#v3.7.0: + run: java-mazerunner + command: 'bundle exec maze-runner --exclude=features/[^a-m].*.feature' + + - label: ':docker: Mazerunner tests batch 2' + key: 'java-mazerunner-tests-2' + timeout_in_minutes: 30 + plugins: + - docker-compose#v3.7.0: + pull: java-mazerunner + run: java-mazerunner + command: 'bundle exec maze-runner --exclude=features/[^n-z].*.feature' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5006a6d6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -sudo: required -dist: trusty -language: java -before_cache: -- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock -- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ -install: ./gradlew :bugsnag:assemble :bugsnag-spring:assemble - -jobs: - include: - - stage: test - jdk: openjdk8 - script: - - ./gradlew check test - - stage: test - jdk: oraclejdk9 - script: - - ./gradlew check test - - stage: test - jdk: oraclejdk8 - script: - - ./gradlew check test - - stage: test - jdk: openjdk7 - script: - - ./gradlew check test - before_install: # Work around missing crypto in openjdk7 - - sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}/jre/lib/ext/bcprov-ext-jdk15on-158.jar" - - sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security - - echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security - - stage: test - name: mazerunner - jdk: openjdk8 - script: - - bundle install - - bundle exec bugsnag-maze-runner diff --git a/CHANGELOG.md b/CHANGELOG.md index fb58c553..572dbb93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 3.6.4 (2022-07-12) + +* Support log messages that use `{}` formatting + [#178](https://github.com/bugsnag/bugsnag-java/pull/178) + +* Fix potential hang when resolving DNS hostname + [#179](https://github.com/bugsnag/bugsnag-java/pull/179) + +* Bump Jackson from 2.12.5 and JUnit from 4.12 for critical vulnerability fixes + [#180](https://github.com/bugsnag/bugsnag-java/pull/180) + ## 3.6.3 (2021-10-12) * Bump Jackson from 2.9.1 for critical vulnerability fixes diff --git a/Gemfile b/Gemfile index 561d6334..7af6d244 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -gem 'bugsnag-maze-runner', :git => 'https://github.com/bugsnag/maze-runner', :branch => 'v1' +gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v6.8.0' gem 'os' diff --git a/Gemfile.lock b/Gemfile.lock index 5cf1a368..f1fe1b94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,102 @@ GIT remote: https://github.com/bugsnag/maze-runner - revision: ba232513f88c18149ab5b4595c9f5a81174bdee5 + revision: fe12189f83aad154f54221ee0fcd41b483d3c0d1 + tag: v6.8.0 specs: - bugsnag-maze-runner (1.0.0) - cucumber (~> 3.1.0) - cucumber-expressions (= 5.0.15) - minitest (~> 5.0) + bugsnag-maze-runner (6.8.0) + appium_lib (~> 11.2.0) + bugsnag (~> 6.24) + cucumber (~> 7.1) + cucumber-expressions (~> 6.0.0) + curb (~> 0.9.6) + optimist (~> 3.0.1) os (~> 1.0.0) - rack (~> 2.0.0) - rake (~> 12.3.0) - test-unit (~> 3.2.0) + rake (~> 12.3.3) + rubyzip (~> 2.3.2) + selenium-webdriver (~> 3.11) + test-unit (~> 3.5.2) + webrick (~> 1.7.0) GEM remote: https://rubygems.org/ specs: - backports (3.11.4) - builder (3.2.3) - cucumber (3.1.0) - builder (>= 2.1.2) - cucumber-core (~> 3.1.0) - cucumber-expressions (~> 5.0.4) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.1.0) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (>= 5.0.0) - cucumber-expressions (5.0.15) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) - diff-lcs (1.3) - gherkin (5.1.0) - minitest (5.11.3) - multi_json (1.13.1) + appium_lib (11.2.0) + appium_lib_core (~> 4.1) + nokogiri (~> 1.8, >= 1.8.1) + tomlrb (~> 1.1) + appium_lib_core (4.7.1) + faye-websocket (~> 0.11.0) + selenium-webdriver (~> 3.14, >= 3.14.1) + bugsnag (6.24.1) + concurrent-ruby (~> 1.0) + builder (3.2.4) + childprocess (3.0.0) + concurrent-ruby (1.1.9) + cucumber (7.1.0) + builder (~> 3.2, >= 3.2.4) + cucumber-core (~> 10.1, >= 10.1.0) + cucumber-create-meta (~> 6.0, >= 6.0.1) + cucumber-cucumber-expressions (~> 14.0, >= 14.0.0) + cucumber-gherkin (~> 22.0, >= 22.0.0) + cucumber-html-formatter (~> 17.0, >= 17.0.0) + cucumber-messages (~> 17.1, >= 17.1.1) + cucumber-wire (~> 6.2, >= 6.2.0) + diff-lcs (~> 1.4, >= 1.4.4) + mime-types (~> 3.3, >= 3.3.1) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.2, >= 1.2.2) + cucumber-core (10.1.0) + cucumber-gherkin (~> 22.0, >= 22.0.0) + cucumber-messages (~> 17.1, >= 17.1.1) + cucumber-tag-expressions (~> 4.0, >= 4.0.2) + cucumber-create-meta (6.0.4) + cucumber-messages (~> 17.1, >= 17.1.1) + sys-uname (~> 1.2, >= 1.2.2) + cucumber-cucumber-expressions (14.0.0) + cucumber-expressions (6.0.1) + cucumber-gherkin (22.0.0) + cucumber-messages (~> 17.1, >= 17.1.1) + cucumber-html-formatter (17.0.0) + cucumber-messages (~> 17.1, >= 17.1.0) + cucumber-messages (17.1.1) + cucumber-tag-expressions (4.1.0) + cucumber-wire (6.2.0) + cucumber-core (~> 10.1, >= 10.1.0) + cucumber-cucumber-expressions (~> 14.0, >= 14.0.0) + cucumber-messages (~> 17.1, >= 17.1.1) + curb (0.9.11) + diff-lcs (1.5.0) + eventmachine (1.2.7) + faye-websocket (0.11.1) + eventmachine (>= 0.12.0) + websocket-driver (>= 0.5.1) + ffi (1.15.4) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2021.1115) + mini_portile2 (2.6.1) multi_test (0.1.2) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) + optimist (3.0.1) os (1.0.0) - power_assert (1.1.3) - rack (2.0.6) - rake (12.3.1) - test-unit (3.2.8) + power_assert (2.0.1) + racc (1.6.0) + rake (12.3.3) + rubyzip (2.3.2) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + sys-uname (1.2.2) + ffi (~> 1.1) + test-unit (3.5.3) power_assert + tomlrb (1.3.0) + webrick (1.7.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) PLATFORMS ruby diff --git a/bugsnag-spring/build.gradle b/bugsnag-spring/build.gradle index d0f6a210..786ac088 100644 --- a/bugsnag-spring/build.gradle +++ b/bugsnag-spring/build.gradle @@ -20,7 +20,7 @@ dependencies { compileOnly "org.springframework.boot:spring-boot:${springBootVersion}" compileOnly "ch.qos.logback:logback-core:${logbackVersion}" - testCompile "junit:junit:4.12" + testCompile "junit:junit:4.13.2" testCompile "javax.servlet:javax.servlet-api:${servletApiVersion}" testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" testCompile "org.springframework.boot:spring-boot-starter-web:${springBootVersion}" diff --git a/bugsnag/build.gradle b/bugsnag/build.gradle index 0f07e1ee..aa2ae9e3 100644 --- a/bugsnag/build.gradle +++ b/bugsnag/build.gradle @@ -10,14 +10,14 @@ repositories { } dependencies { - compile "com.fasterxml.jackson.core:jackson-databind:2.12.5" + compile "com.fasterxml.jackson.core:jackson-databind:2.13.3" compile "org.slf4j:slf4j-api:1.7.25" compileOnly "javax.servlet:javax.servlet-api:${servletApiVersion}" compileOnly("ch.qos.logback:logback-classic:${logbackVersion}") { exclude group: "org.slf4j" } - testCompile "junit:junit:4.12" + testCompile "junit:junit:4.13.2" testCompile "org.slf4j:log4j-over-slf4j:1.7.25" testCompile "javax.servlet:javax.servlet-api:${servletApiVersion}" testCompile "org.mockito:mockito-core:2.10.0" diff --git a/bugsnag/src/main/java/com/bugsnag/BugsnagAppender.java b/bugsnag/src/main/java/com/bugsnag/BugsnagAppender.java index cfd9f88f..753a1a28 100644 --- a/bugsnag/src/main/java/com/bugsnag/BugsnagAppender.java +++ b/bugsnag/src/main/java/com/bugsnag/BugsnagAppender.java @@ -138,7 +138,7 @@ public void beforeNotify(Report report) { // Add some data from the logging event report.addToTab("Log event data", - "Message", event.getMessage()); + "Message", event.getFormattedMessage()); report.addToTab("Log event data", "Logger name", event.getLoggerName()); diff --git a/bugsnag/src/main/java/com/bugsnag/Notifier.java b/bugsnag/src/main/java/com/bugsnag/Notifier.java index 8f838e34..e3f3c608 100644 --- a/bugsnag/src/main/java/com/bugsnag/Notifier.java +++ b/bugsnag/src/main/java/com/bugsnag/Notifier.java @@ -5,7 +5,7 @@ class Notifier { private static final String NOTIFIER_NAME = "Bugsnag Java"; - private static final String NOTIFIER_VERSION = "3.6.3"; + private static final String NOTIFIER_VERSION = "3.6.4"; private static final String NOTIFIER_URL = "https://github.com/bugsnag/bugsnag-java"; private String notifierName = NOTIFIER_NAME; diff --git a/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java b/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java index 8ee7e57c..e6d21297 100644 --- a/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java +++ b/bugsnag/src/main/java/com/bugsnag/callbacks/DeviceCallback.java @@ -5,12 +5,18 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Locale; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class DeviceCallback implements Callback { private static volatile String hostname; - private static transient volatile boolean hostnameInitialised; + private static volatile boolean hostnameInitialised; private static final Object LOCK = new Object(); + private static final int HOSTNAME_LOOKUP_TIMEOUT = 10000; /** * Memoises the hostname, as lookup can be expensive @@ -39,17 +45,42 @@ private static String lookupHostname() { return hostname; } - // Resort to dns hostname lookup + // Resort to dns hostname lookup with a timeout of HOSTNAME_LOOKUP_TIMEOUT, + // as this can potentially take a very long time to resolve + FutureTask future = new FutureTask(new Callable() { + @Override + public String call() throws UnknownHostException { + return InetAddress.getLocalHost().getHostName(); + } + }); + Thread resolverThread = new Thread(future, "Hostname Resolver"); + resolverThread.setDaemon(true); + resolverThread.start(); + try { - return InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ex) { + return future.get(HOSTNAME_LOOKUP_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (ExecutionException ex) { + // Give up + } catch (InterruptedException ex) { + // Give up + } catch (TimeoutException ex) { // Give up } return null; } + /** + * Cache the hostname on a background thread to avoid blocking on initialization + */ public static void initializeCache() { - getHostnameValue(); + Thread hostnameLookup = new Thread("Hostname Lookup") { + @Override + public void run() { + getHostnameValue(); + } + }; + hostnameLookup.setDaemon(true); + hostnameLookup.start(); } @Override diff --git a/bugsnag/src/test/java/com/bugsnag/AppenderTest.java b/bugsnag/src/test/java/com/bugsnag/AppenderTest.java index bba73067..19c9ad42 100644 --- a/bugsnag/src/test/java/com/bugsnag/AppenderTest.java +++ b/bugsnag/src/test/java/com/bugsnag/AppenderTest.java @@ -30,6 +30,9 @@ public class AppenderTest { private static final Logger LOGGER = Logger.getLogger(AppenderTest.class); + + private static final org.slf4j.Logger SLF_LOGGER = LoggerFactory.getLogger(AppenderTest.class); + private StubNotificationDelivery delivery; private StubSessionDelivery sessionDelivery; private Delivery originalDelivery; @@ -87,6 +90,28 @@ public void testSimpleException() { getMetaDataMap(notification, "Log event data").get("Message")); } + @Test + public void testFormattedMessage() { + int value = 1234; + + // Send a test log + SLF_LOGGER.warn("Test exception, errorCode: {}", value, new RuntimeException("test")); + + String message = "no exception"; + // Send a log with no exception + SLF_LOGGER.warn("Test log with {}", message); + + // Check that one report was sent to Bugsnag + assertEquals(1, delivery.getNotifications().size()); + + // Check the correct event was created + Notification notification = delivery.getNotifications().get(0); + assertEquals("test", notification.getEvents().get(0).getExceptionMessage()); + assertEquals(Severity.WARNING.getValue(), notification.getEvents().get(0).getSeverity()); + assertEquals("Test exception, errorCode: " + value, + getMetaDataMap(notification, "Log event data").get("Message")); + } + @Test public void testExceptionSeverities() { diff --git a/docker-compose.yml b/docker-compose.yml index b7d1cfd0..d6a188bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,3 +4,11 @@ services: build: context: . dockerfile: dockerfiles/Dockerfile.license-audit + java-common: + build: + context: . + dockerfile: dockerfiles/Dockerfile.java-common + java-mazerunner: + build: + context: . + dockerfile: dockerfiles/Dockerfile.java-mazerunner diff --git a/dockerfiles/Dockerfile.java-common b/dockerfiles/Dockerfile.java-common new file mode 100644 index 00000000..9ed9fa29 --- /dev/null +++ b/dockerfiles/Dockerfile.java-common @@ -0,0 +1,13 @@ +FROM openjdk:8 +WORKDIR /app + +# Force download of gradle zip early to avoid repeating +# if Docker cache is invalidated by branch changes. +COPY gradlew gradle.properties /app/ +COPY gradle/ /app/gradle/ +ENV GRADLE_OPTS="-Dorg.gradle.daemon=false" +COPY settings.gradle /app/ +RUN ./gradlew + +# Copy repo into docker +COPY . /app diff --git a/dockerfiles/Dockerfile.java-mazerunner b/dockerfiles/Dockerfile.java-mazerunner new file mode 100644 index 00000000..2ca0aad8 --- /dev/null +++ b/dockerfiles/Dockerfile.java-mazerunner @@ -0,0 +1,20 @@ +FROM tomcat:9.0.56-jdk8 +WORKDIR /app + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive \ + apt-get install -y -q docker-compose bundler libcurl4-openssl-dev + +# Force download of gradle zip early to avoid repeating +# if Docker cache is invalidated by branch changes. +COPY gradlew gradle.properties /app/ +COPY gradle/ /app/gradle/ +ENV GRADLE_OPTS="-Dorg.gradle.daemon=false" +COPY settings.gradle /app/ +RUN ./gradlew + +# Copy repo into docker +COPY . /app + +# Setup mazerunner +RUN gem install bundler:1.16.5 +RUN bundle install diff --git a/features/app_type.feature b/features/app_type.feature index 79ded8b6..1c844fe5 100644 --- a/features/app_type.feature +++ b/features/app_type.feature @@ -2,31 +2,32 @@ Feature: Reporting app version Scenario: Test logback appender with app type 'testAppType' When I run "LogbackScenario" with logback config "app_type_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "app.type" equals "testAppType" Scenario: Test Java app with app type 'testAppType' When I run "AppTypeScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "AppTypeScenario" And the event "app.type" equals "testAppType" Scenario: Test Spring Boot app with app type 'testAppType' When I run spring boot "AppTypeScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "AppTypeScenario" And the event "app.type" equals "testAppType" Scenario: Test Spring app with app type 'testAppType' - When I run plain Spring "AppTypeScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + When I run the plain spring app + And I wait for 20 seconds + And I navigate to the route "/run-scenario/AppTypeScenario" on port "8080" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "AppTypeScenario" And the event "app.type" equals "testAppType" diff --git a/features/app_version.feature b/features/app_version.feature index 9c10d5a6..08e58dc5 100644 --- a/features/app_version.feature +++ b/features/app_version.feature @@ -2,34 +2,33 @@ Feature: Reporting app version Scenario: Test Java handled Exception When I run "AppVersionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "AppVersionScenario" And the event "app.version" equals "1.2.3.abc" Scenario: Test Spring Boot handled Exception When I run spring boot "AppVersionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "AppVersionScenario" And the event "app.version" equals "1.2.3.abc" Scenario: Test plain Spring handled Exception When I run plain Spring "AppVersionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "AppVersionScenario" And the event "app.version" equals "1.2.3.abc" Scenario: Test logback appender with app version 1.2.3 When I run "LogbackScenario" with logback config "app_version_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "app.version" equals "1.2.3" \ No newline at end of file diff --git a/features/async_method.feature b/features/async_method.feature index a8fffd16..9c844438 100644 --- a/features/async_method.feature +++ b/features/async_method.feature @@ -2,11 +2,9 @@ Feature: Reporting Unhandled exceptions in an async method Scenario: Report an exception from a spring boot async method When I run spring boot "AsyncMethodScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the exception "errorClass" equals "java.lang.RuntimeException" @@ -16,27 +14,26 @@ Scenario: Report an exception from a spring boot async method Scenario: Notify an exception from a spring boot async method When I run spring boot "AsyncNotifyScenario" with the defaults - Then I should receive 2 requests - And the request 0 is a valid for the error reporting API - And the exception "errorClass" equals "java.lang.RuntimeException" for request 0 - And the exception "message" equals "test from before async" for request 0 - And the event "metaData.thread.controllerMethod" equals "meta data from controller method" for request 0 - And the event "metaData.thread.inAsyncMethod" is null for request 0 + Then I wait to receive 2 errors + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the exception "errorClass" equals "java.lang.RuntimeException" + And the exception "message" equals "test from before async" + And the event "metaData.thread.controllerMethod" equals "meta data from controller method" + And the event "metaData.thread.inAsyncMethod" is null + Then I discard the oldest error - And the request 1 is a valid for the error reporting API - And the exception "errorClass" equals "java.lang.RuntimeException" for request 1 - And the exception "message" equals "test from async" for request 1 - And the event "metaData.thread.controllerMethod" is null for request 1 - And the event "metaData.thread.inAsyncMethod" equals "meta data from async method" for request 1 + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the exception "errorClass" equals "java.lang.RuntimeException" + And the exception "message" equals "test from async" + And the event "metaData.thread.controllerMethod" is null + And the event "metaData.thread.inAsyncMethod" equals "meta data from async method" Scenario: Report an exception from a plain spring async method Given I run the plain spring app - When I navigate to the route "/run-async-task" on port "1235" - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + When I navigate to the route "/run-async-task" on port "8080" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the exception "errorClass" equals "java.lang.RuntimeException" diff --git a/features/crash_handler.feature b/features/crash_handler.feature index 1d28a561..0b20f5d4 100644 --- a/features/crash_handler.feature +++ b/features/crash_handler.feature @@ -2,27 +2,24 @@ Feature: Reporting with other exception handlers installed Scenario: Other uncaught exception handler installed in Java app When I run "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "CrashHandlerScenario" Scenario: Other uncaught exception handler installed in Spring Boot app When I run spring boot "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "CrashHandlerScenario" Scenario: Other uncaught exception handler installed in Spring app When I run plain Spring "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "CrashHandlerScenario" \ No newline at end of file diff --git a/features/empty_stacktrace.feature b/features/empty_stacktrace.feature index 8ebd2ee7..a94cf1a7 100644 --- a/features/empty_stacktrace.feature +++ b/features/empty_stacktrace.feature @@ -2,27 +2,24 @@ Feature: Empty Stacktrace reported Scenario: Exceptions with empty stacktraces are sent in plain Java app When I run "EmptyStacktraceScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "com.bugsnag.mazerunner.scenarios.EmptyStacktraceScenario$EmptyException" - And the payload field "events.0.exceptions.0.stacktrace" is null + And the error payload field "events.0.exceptions.0.stacktrace" is null Scenario: Exceptions with empty stacktraces are sent in Spring Boot app When I run spring boot "EmptyStacktraceScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "com.bugsnag.mazerunner.scenarios.EmptyStacktraceScenario$EmptyException" - And the payload field "events.0.exceptions.0.stacktrace" is null + And the error payload field "events.0.exceptions.0.stacktrace" is null Scenario: Exceptions with empty stacktraces are sent in Spring app When I run plain Spring "EmptyStacktraceScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "com.bugsnag.mazerunner.scenarios.EmptyStacktraceScenario$EmptyException" - And the payload field "events.0.exceptions.0.stacktrace" is null + And the error payload field "events.0.exceptions.0.stacktrace" is null diff --git a/features/error_context.feature b/features/error_context.feature index b98cbbfe..e4b4c4af 100644 --- a/features/error_context.feature +++ b/features/error_context.feature @@ -3,14 +3,14 @@ Feature: Reporting Error Context Scenario: Context automatically set in plain Java app When I run "AutoContextScenario" with the defaults And I wait for 3 seconds - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "AutoContextScenario" And the event "context" is null Scenario: Context manually set in plain Java app When I run "ManualContextScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "ManualContextScenario" And the event "context" equals "FooContext" diff --git a/features/filtering_metadata.feature b/features/filtering_metadata.feature index e261db20..db8aacbf 100644 --- a/features/filtering_metadata.feature +++ b/features/filtering_metadata.feature @@ -2,9 +2,8 @@ Feature: Metadata is filtered Scenario: Using the default metadata filter When I run "AutoFilterScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "AutoFilterScenario" And the event "metaData.custom.foo" equals "hunter2" And the event "metaData.custom.password" equals "[FILTERED]" @@ -12,9 +11,8 @@ Scenario: Using the default metadata filter Scenario: Adding a custom metadata filter When I run "ManualFilterScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "ManualFilterScenario" And the event "metaData.custom.foo" equals "[FILTERED]" And the event "metaData.user.foo" equals "[FILTERED]" @@ -22,18 +20,16 @@ Scenario: Adding a custom metadata filter Scenario: Adding a thread metadata filter using logback When I run "LogbackThreadMetaDataScenario" with logback config "meta_data_filter_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "LogbackThreadMetaDataScenario" And the event "metaData.thread.foo" equals "[FILTERED]" And the event "metaData.thread.bar" equals "threadvalue2" Scenario: Adding a custom metadata filter using logback When I run "LogbackMetaDataScenario" with logback config "meta_data_filter_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "LogbackMetaDataScenario" And the event "metaData.custom.foo" equals "[FILTERED]" And the event "metaData.user.foo" equals "[FILTERED]" @@ -41,8 +37,8 @@ Scenario: Adding a custom metadata filter using logback Scenario: Using the default metadata filter in Spring Boot app When I run spring boot "AutoFilterScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "AutoFilterScenario" And the event "metaData.custom.foo" equals "hunter2" And the event "metaData.custom.password" equals "[FILTERED]" @@ -50,8 +46,8 @@ Scenario: Using the default metadata filter in Spring Boot app Scenario: Using the default metadata filter in Spring app When I run plain Spring "AutoFilterScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "AutoFilterScenario" And the event "metaData.custom.foo" equals "hunter2" And the event "metaData.custom.password" equals "[FILTERED]" diff --git a/features/fixtures/docker-compose.yml b/features/fixtures/docker-compose.yml deleted file mode 100644 index 00280623..00000000 --- a/features/fixtures/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '3.4' -services: - plainspringapp: - build: - context: mazerunnerplainspring - environment: - - BUGSNAG_API_KEY - - MOCK_API_PATH - - RUN_SCHEDULED_TASK - - AUTO_CAPTURE_SESSIONS - ports: - - "1235:8080" - restart: "no" \ No newline at end of file diff --git a/features/fixtures/logback/app_type_config.xml b/features/fixtures/logback/app_type_config.xml index 9188e199..60ade3a1 100644 --- a/features/fixtures/logback/app_type_config.xml +++ b/features/fixtures/logback/app_type_config.xml @@ -3,13 +3,13 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 testAppType - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/app_version_config.xml b/features/fixtures/logback/app_version_config.xml index a34789c0..9e938da6 100644 --- a/features/fixtures/logback/app_version_config.xml +++ b/features/fixtures/logback/app_version_config.xml @@ -3,11 +3,11 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.2.3 - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/basic_config.xml b/features/fixtures/logback/basic_config.xml index d24ee524..83f088f5 100644 --- a/features/fixtures/logback/basic_config.xml +++ b/features/fixtures/logback/basic_config.xml @@ -3,11 +3,11 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/ignore_release_stage_config.xml b/features/fixtures/logback/ignore_release_stage_config.xml index ea4fe6ec..95b1da88 100644 --- a/features/fixtures/logback/ignore_release_stage_config.xml +++ b/features/fixtures/logback/ignore_release_stage_config.xml @@ -3,14 +3,14 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa staging 1.0.0 production development - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/ignored_class_config.xml b/features/fixtures/logback/ignored_class_config.xml index 7cf9df13..75577a21 100644 --- a/features/fixtures/logback/ignored_class_config.xml +++ b/features/fixtures/logback/ignored_class_config.xml @@ -3,13 +3,13 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 java.lang.RuntimeException - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/meta_data_config.xml b/features/fixtures/logback/meta_data_config.xml index 36db0566..48704afb 100644 --- a/features/fixtures/logback/meta_data_config.xml +++ b/features/fixtures/logback/meta_data_config.xml @@ -3,7 +3,7 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 @@ -21,7 +21,7 @@ - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/meta_data_filter_config.xml b/features/fixtures/logback/meta_data_filter_config.xml index f43cf0f0..e036b689 100644 --- a/features/fixtures/logback/meta_data_filter_config.xml +++ b/features/fixtures/logback/meta_data_filter_config.xml @@ -3,13 +3,13 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 foo - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/project_package_config.xml b/features/fixtures/logback/project_package_config.xml index 4e549211..be0890ad 100644 --- a/features/fixtures/logback/project_package_config.xml +++ b/features/fixtures/logback/project_package_config.xml @@ -3,13 +3,13 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 com.bugsnag.mazerunner - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/release_stage_config.xml b/features/fixtures/logback/release_stage_config.xml index f1889e52..583e8f27 100644 --- a/features/fixtures/logback/release_stage_config.xml +++ b/features/fixtures/logback/release_stage_config.xml @@ -3,11 +3,11 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa staging 1.0.0 - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify diff --git a/features/fixtures/logback/threads_config.xml b/features/fixtures/logback/threads_config.xml index 45b8562f..f3544adb 100644 --- a/features/fixtures/logback/threads_config.xml +++ b/features/fixtures/logback/threads_config.xml @@ -3,11 +3,11 @@ - __BUGSNAG_API_KEY__ + a35a2a72bd230ac0aa0f52715bbdc6aa production 1.0.0 - __BUGSNAG_MOCK_PATH__ + http://localhost:9339/notify true diff --git a/features/fixtures/mazerunner/build.gradle b/features/fixtures/mazerunner/build.gradle index 410b195a..235886a6 100644 --- a/features/fixtures/mazerunner/build.gradle +++ b/features/fixtures/mazerunner/build.gradle @@ -35,6 +35,6 @@ dependencies { compile("com.bugsnag:bugsnag:9.9.9-test") compile project(":scenarios") - testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'junit', name: 'junit', version: '4.13.2' } diff --git a/features/fixtures/mazerunner/src/main/java/com/bugsnag/mazerunner/TestCaseRunner.java b/features/fixtures/mazerunner/src/main/java/com/bugsnag/mazerunner/TestCaseRunner.java index 507b1f0b..babe0c0b 100644 --- a/features/fixtures/mazerunner/src/main/java/com/bugsnag/mazerunner/TestCaseRunner.java +++ b/features/fixtures/mazerunner/src/main/java/com/bugsnag/mazerunner/TestCaseRunner.java @@ -32,12 +32,13 @@ public void run(String... args) { // Create and run the test case LOGGER.info("Creating test case"); - Scenario scenario = testCaseForName(System.getenv("EVENT_TYPE")); + String type = System.getenv("EVENT_TYPE"); + Scenario scenario = testCaseForName(type); if (scenario != null) { - LOGGER.info("running test case"); + LOGGER.info("running test case " + type); scenario.run(); } else { - LOGGER.error("No test case found for " + System.getenv("EVENT_TYPE")); + LOGGER.error("No test case found for " + type); } } @@ -48,16 +49,16 @@ private void setupBugsnag() { LOGGER.info("got " + apiKey + " from env vars"); } - String path = "http://localhost:9339"; - if (System.getenv("MOCK_API_PATH") != null) { - path = System.getenv("MOCK_API_PATH"); + String path = "http://localhost:9339/"; + if (System.getenv("MAZERUNNER_BASE_URL") != null) { + path = System.getenv("MAZERUNNER_BASE_URL"); LOGGER.info("got " + path + " from env vars"); } LOGGER.info("using " + path + " to send Bugsnags"); bugsnag = new Bugsnag(apiKey, true); - bugsnag.setEndpoints(path, path); + bugsnag.setEndpoints(path + "notify", path + "sessions"); } private Scenario testCaseForName(String eventType) { diff --git a/features/fixtures/mazerunnerplainspring/Dockerfile b/features/fixtures/mazerunnerplainspring/Dockerfile deleted file mode 100644 index 5c293384..00000000 --- a/features/fixtures/mazerunnerplainspring/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM tomcat:7.0 - -COPY /build/libs/mazerunnerplainspring.war /usr/local/tomcat/webapps/ROOT.war diff --git a/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/BugsnagConfig.java b/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/BugsnagConfig.java index 7f878af8..cf5d52ca 100644 --- a/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/BugsnagConfig.java +++ b/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/BugsnagConfig.java @@ -16,7 +16,7 @@ public class BugsnagConfig { @Value("${BUGSNAG_API_KEY}") private String bugsnagApiKey; - @Value("${MOCK_API_PATH}") + @Value("${MAZERUNNER_BASE_URL}") private String bugsnagEndpoint; @Value("${AUTO_CAPTURE_SESSIONS:false}") @@ -25,7 +25,7 @@ public class BugsnagConfig { @Bean public Bugsnag bugsnag() { Bugsnag bugsnag = new Bugsnag(bugsnagApiKey); - bugsnag.setEndpoints(bugsnagEndpoint, bugsnagEndpoint); + bugsnag.setEndpoints(bugsnagEndpoint + "notify", bugsnagEndpoint + "sessions"); bugsnag.setAutoCaptureSessions(autoCaptureSessions); bugsnag.setReleaseStage("production"); bugsnag.setAppVersion("1.0.0"); diff --git a/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/TestRestController.java b/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/TestRestController.java index 36b38462..59496a2f 100644 --- a/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/TestRestController.java +++ b/features/fixtures/mazerunnerplainspring/src/main/java/com.bugsnag.mazerunnerplainspring/TestRestController.java @@ -44,6 +44,7 @@ public void addSession() { // Flush sessions now, otherwise need to wait for sessions to be automatically flushed flushAllSessions(); + LOGGER.info("Flushed all sessions"); } @RequestMapping("/run-async-task") diff --git a/features/fixtures/mazerunnerspringboot/build.gradle b/features/fixtures/mazerunnerspringboot/build.gradle index e7e9ae5c..43bbd822 100644 --- a/features/fixtures/mazerunnerspringboot/build.gradle +++ b/features/fixtures/mazerunnerspringboot/build.gradle @@ -40,5 +40,5 @@ dependencies { // required for JDK 9 and above compile('javax.xml.bind:jaxb-api:2.3.0') - testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'junit', name: 'junit', version: '4.13.2' } \ No newline at end of file diff --git a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunner/scenarios/AutoSessionScenario.java b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunner/scenarios/AutoSessionScenario.java index 6c53fc7c..8058edd9 100644 --- a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunner/scenarios/AutoSessionScenario.java +++ b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunner/scenarios/AutoSessionScenario.java @@ -21,10 +21,10 @@ public void run() { try { RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject(uri, String.class); - + LOGGER.info("Completed auto session request: " + result); Thread.sleep(2000); } catch (Exception ex) { - // ignore + LOGGER.error("Failed to complete request", ex); } flushAllSessions(); diff --git a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/Config.java b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/Config.java index 4bd8b323..35b7d45d 100644 --- a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/Config.java +++ b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/Config.java @@ -14,13 +14,13 @@ public class Config { @Value("${BUGSNAG_API_KEY}") private String bugsnagApiKey; - @Value("${MOCK_API_PATH}") + @Value("${MAZERUNNER_BASE_URL}") private String bugsnagEndpoint; @Bean public Bugsnag bugsnag() { Bugsnag bugsnag = new Bugsnag(bugsnagApiKey); - bugsnag.setEndpoints(bugsnagEndpoint, bugsnagEndpoint); + bugsnag.setEndpoints(bugsnagEndpoint + "notify", bugsnagEndpoint + "sessions"); bugsnag.setReleaseStage("production"); bugsnag.setAppVersion("1.0.0"); return bugsnag; diff --git a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/TestCaseRunner.java b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/TestCaseRunner.java index 8a2015f9..82839269 100644 --- a/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/TestCaseRunner.java +++ b/features/fixtures/mazerunnerspringboot/src/main/java/com/bugsnag/mazerunnerspringboot/TestCaseRunner.java @@ -34,12 +34,13 @@ public void setApplicationContext(ApplicationContext applicationContext) throws public void run(String... args) { // Create and run the test case LOGGER.info("Creating test case"); - Scenario scenario = testCaseForName(System.getenv("EVENT_TYPE")); + String type = System.getenv("EVENT_TYPE"); + Scenario scenario = testCaseForName(type); if (scenario != null) { - LOGGER.info("running test case"); + LOGGER.info("running test case " + type); scenario.run(); } else { - LOGGER.error("No test case found for " + System.getenv("EVENT_TYPE")); + LOGGER.error("No test case found for " + type); } // Exit the application diff --git a/features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/Scenario.java b/features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/Scenario.java index 83a5cac3..84c066fa 100644 --- a/features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/Scenario.java +++ b/features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/Scenario.java @@ -16,7 +16,7 @@ public abstract class Scenario { - private static final Logger LOGGER = LoggerFactory.getLogger(Scenario.class); + protected static final Logger LOGGER = LoggerFactory.getLogger(Scenario.class); protected Bugsnag bugsnag; diff --git a/features/handled_exception.feature b/features/handled_exception.feature index 863b40d2..f79faf69 100644 --- a/features/handled_exception.feature +++ b/features/handled_exception.feature @@ -2,27 +2,24 @@ Feature: Reporting handled Exceptions Scenario: Test Java app handled Exception When I run "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledExceptionScenario" Scenario: Test Spring Boot handled Exception When I run spring boot "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledExceptionScenario" Scenario: Test Spring handled Exception When I run plain Spring "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledExceptionScenario" diff --git a/features/logback.feature b/features/logback.feature index d46bee0a..003dfa20 100644 --- a/features/logback.feature +++ b/features/logback.feature @@ -2,10 +2,9 @@ Feature: Using the logback appender Scenario: Test logback appender When I run "LogbackScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "app.releaseStage" equals "production" diff --git a/features/meta_data.feature b/features/meta_data.feature index 428d4d66..99c0b3ae 100644 --- a/features/meta_data.feature +++ b/features/meta_data.feature @@ -2,48 +2,45 @@ Feature: Reporting metadata Scenario: Sends a handled exception which includes custom metadata added in a notify callback When I run "MetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the event "metaData.Custom.foo" equals "Hello World!" Scenario: Sends a handled exception which includes custom metadata added in a notify callback for Spring Boot app When I run spring boot "MetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.Custom.foo" equals "Hello World!" Scenario: Sends a handled exception which includes custom metadata added in a notify callback for plain Spring app When I run plain Spring "MetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.Custom.foo" equals "Hello World!" Scenario: Test logback appender with meta data in the config file When I run "LogbackScenario" with logback config "meta_data_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.configTab.foo" equals "tabValue1" And the event "metaData.configTab.bar" equals "tabValue2" Scenario: Test logback appender with thread meta data When I run "LogbackThreadMetaDataScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.thread.foo" equals "threadvalue1" And the event "metaData.thread.bar" equals "threadvalue2" Scenario: Test logback appender with meta data in a callback When I run "LogbackMetaDataScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.user.foo" equals "hunter2" And the event "metaData.custom.foo" equals "hunter2" @@ -51,20 +48,18 @@ Scenario: Test logback appender with meta data in a callback Scenario: Test logback appender with meta data from the MDC When I run "LogbackMDCScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Context.foo" equals "hunter2" And the event "metaData.Context.bar" equals "hunter2" Scenario: Test thread meta data When I run "ThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value" @@ -73,10 +68,9 @@ Scenario: Test thread meta data Scenario: Test thread meta data for Spring Boot app When I run spring boot "ThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value" @@ -85,10 +79,9 @@ Scenario: Test thread meta data for Spring Boot app Scenario: Test thread meta data for plain Spring app When I run plain Spring "ThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value" @@ -97,10 +90,9 @@ Scenario: Test thread meta data for plain Spring app Scenario: Test unhandled thread meta data When I run "UnhandledThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value 1" @@ -109,10 +101,9 @@ Scenario: Test unhandled thread meta data Scenario: Test unhandled thread meta data for Spring Boot app When I run spring boot "UnhandledThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value 1" @@ -121,10 +112,9 @@ Scenario: Test unhandled thread meta data for Spring Boot app Scenario: Test unhandled thread meta data for plain Spring app When I run plain Spring "UnhandledThreadMetaDataScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.Custom.test" equals "Global value" And the event "metaData.Custom.foo" equals "Thread value 1" @@ -133,10 +123,9 @@ Scenario: Test unhandled thread meta data for plain Spring app Scenario: Test logback appender with thread meta data When I run "LogbackThreadMetaDataScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the event "metaData.thread.foo" equals "threadvalue1" And the event "metaData.thread.bar" equals "threadvalue2" @@ -144,31 +133,31 @@ Scenario: Test logback appender with thread meta data Scenario: Test thread meta data in plain spring async method Given I run the plain spring app - When I navigate to the route "/run-async-task" on port "1235" - Then I should receive a request - And the request is a valid for the error reporting API + When I navigate to the route "/run-async-task" on port "8080" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.thread.key1" is null And the event "metaData.thread.key2" equals "should be included in meta data" Scenario: Test thread meta data in spring boot async method When I run spring boot "AsyncMethodScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.thread.key1" is null And the event "metaData.thread.key2" equals "should be included in meta data" Scenario: Test thread meta data in plain spring scheduled task Given I set environment variable "RUN_SCHEDULED_TASK" to "true" And I run the plain spring app - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.thread.key1" is null And the event "metaData.thread.key2" equals "should be included in meta data" Scenario: Test thread meta data in spring boot scheduled task When I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.thread.key1" is null And the event "metaData.thread.key2" equals "should be included in meta data" diff --git a/features/notify_release_stage.feature b/features/notify_release_stage.feature index a5e4e04c..300afe3c 100644 --- a/features/notify_release_stage.feature +++ b/features/notify_release_stage.feature @@ -14,20 +14,20 @@ Scenario: Exception not reported when outside release stage in plain Spring app Scenario: Exception reported when inside release stage When I run "InsideReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "InsideReleaseStageScenario" Scenario: Exception reported when inside release stage in Spring Boot app When I run spring boot "InsideReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "InsideReleaseStageScenario" Scenario: Exception reported when inside release stage in plain Spring app When I run plain Spring "InsideReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "InsideReleaseStageScenario" Scenario: Exception not reported when release stage null in plain Java app @@ -36,15 +36,15 @@ Scenario: Exception not reported when release stage null in plain Java app Scenario: Exception reported when release stages null in plain Java app When I run "NullNotifyReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "NullNotifyReleaseStageScenario" Scenario: Exception reported when inside Notify release stage array in plain Java app When I run "ArrayNotifyReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "ArrayNotifyReleaseStageScenario" diff --git a/features/project_package.feature b/features/project_package.feature index 1349b415..e2dbc6c5 100644 --- a/features/project_package.feature +++ b/features/project_package.feature @@ -2,10 +2,9 @@ Feature: Specifying the project packages Scenario: Test logback appender with no project packages When I run "LogbackScenario" with logback config "basic_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "exceptions.0.stacktrace.0.method" equals "com.bugsnag.mazerunner.scenarios.Scenario.generateException" @@ -19,10 +18,9 @@ Scenario: Test logback appender with no project packages Scenario: Test logback appender with a project package "com.bugsnag.mazerunner" defined When I run "LogbackScenario" with logback config "project_package_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "exceptions.0.stacktrace.0.method" equals "com.bugsnag.mazerunner.scenarios.Scenario.generateException" @@ -36,9 +34,9 @@ Scenario: Test logback appender with a project package "com.bugsnag.mazerunner" Scenario: Test plain Java app with no project packages When I run "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "message" equals "HandledExceptionScenario" And the event "exceptions.0.stacktrace.0.method" equals "com.bugsnag.mazerunner.scenarios.Scenario.generateException" And the event "exceptions.0.stacktrace.0.inProject" is false @@ -51,9 +49,9 @@ Scenario: Test plain Java app with no project packages Scenario: Test plain Java app with a project package "com.bugsnag.mazerunner" defined When I run "ProjectPackageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "message" equals "ProjectPackageScenario" And the event "exceptions.0.stacktrace.0.method" equals "com.bugsnag.mazerunner.scenarios.Scenario.generateException" And the event "exceptions.0.stacktrace.0.inProject" is true diff --git a/features/release_stage.feature b/features/release_stage.feature index 5ded238a..7c65e307 100644 --- a/features/release_stage.feature +++ b/features/release_stage.feature @@ -2,28 +2,27 @@ Feature: Reporting events with different release stages Scenario: Test logback appender with staging release stage When I run "LogbackScenario" with logback config "release_stage_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" And the event "app.releaseStage" equals "staging" Scenario: Test Java app with staging release stage When I run "ReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the event "app.releaseStage" equals "staging" Scenario: Test Spring Boot app with staging release stage When I run spring boot "ReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "app.releaseStage" equals "staging" Scenario: Test Spring app with staging release stage When I run plain Spring "ReleaseStageScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "app.releaseStage" equals "staging" diff --git a/features/rest_controller.feature b/features/rest_controller.feature index 927983ab..a302310a 100644 --- a/features/rest_controller.feature +++ b/features/rest_controller.feature @@ -2,11 +2,9 @@ Feature: Reporting Unhandled exceptions in a rest controller Scenario: Report an exception from a spring boot rest controller When I run spring boot "RestControllerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the event "context" equals "GET /send-unhandled-exception" @@ -18,12 +16,10 @@ Scenario: Report an exception from a spring boot rest controller Scenario: Report an exception from a plain spring rest controller Given I run the plain spring app - When I navigate to the route "/send-unhandled-exception" on port "1235" - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + When I navigate to the route "/send-unhandled-exception" on port "8080" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the event "context" equals "GET /send-unhandled-exception" diff --git a/features/runtime_versions.feature b/features/runtime_versions.feature index c40afda2..6e0025bc 100644 --- a/features/runtime_versions.feature +++ b/features/runtime_versions.feature @@ -4,50 +4,50 @@ Feature: Runtime versions are included in all requests Scenario: Runtime versions included in Plain Java error When I run "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is valid for the error reporting API - And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the error payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Framework error When I run plain Spring "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is valid for the error reporting API - And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" - And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the error payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And the error payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Boot error When I run spring boot "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is valid for the error reporting API - And the payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" - And the payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" - And the payload field "events.0.device.runtimeVersions.springBoot" matches the regex "(\d.)+" + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events.0.device.runtimeVersions.javaType" ends with "Runtime Environment" + And the error payload field "events.0.device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And the error payload field "events.0.device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And the error payload field "events.0.device.runtimeVersions.springBoot" matches the regex "(\d.)+" ### Sessions Scenario: Runtime versions included in Plain Java session When I run "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is valid for the session tracking API - And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Java" notifier + And the session payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the session payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Framework session When I run plain Spring "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is valid for the session tracking API - And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" - And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Spring" notifier + And the session payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the session payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And the session payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" Scenario: Runtime versions included in Spring Boot session When I run spring boot "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is valid for the session tracking API - And the payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" - And the payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" - And the payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" - And the payload field "device.runtimeVersions.springBoot" matches the regex "(\d.)+" + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Spring" notifier + And the session payload field "device.runtimeVersions.javaType" ends with "Runtime Environment" + And the session payload field "device.runtimeVersions.javaVersion" matches the regex "(\d.)+" + And the session payload field "device.runtimeVersions.springFramework" matches the regex "(\d.)+" + And the session payload field "device.runtimeVersions.springBoot" matches the regex "(\d.)+" diff --git a/features/scheduled_task.feature b/features/scheduled_task.feature index 415e7d3d..63361239 100644 --- a/features/scheduled_task.feature +++ b/features/scheduled_task.feature @@ -2,11 +2,9 @@ Feature: Reporting Unhandled exceptions in a scheduled task Scenario: Report an exception from a spring boot scheduled task When I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the exception "errorClass" equals "java.lang.RuntimeException" @@ -17,11 +15,9 @@ Scenario: Report an exception from a spring boot scheduled task Scenario: Report an exception from a plain spring scheduled task Given I set environment variable "RUN_SCHEDULED_TASK" to "true" And I run the plain spring app - Then I should receive a request - And the request is a valid for the error reporting API - And the request used the Spring notifier - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "unhandled" is true And the event "severity" equals "error" And the exception "errorClass" equals "java.lang.RuntimeException" diff --git a/features/scheduled_task_executor.feature b/features/scheduled_task_executor.feature index 6c8d7fca..f2fbac70 100644 --- a/features/scheduled_task_executor.feature +++ b/features/scheduled_task_executor.feature @@ -2,43 +2,43 @@ Feature: Verifies that unhandled exceptions in scheduled tasks are reported to B Scenario: By default a single-threaded ThreadPoolTaskScheduler is used When I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "Unhandled exception from ScheduledTaskService" Scenario: A TaskScheduler supplied as a bean is used Given I set environment variable "custom_task_scheduler_bean" to "true" And I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "Unhandled exception from ScheduledTaskService" Scenario: A ScheduledExecutorService supplied as a bean is used Given I set environment variable "scheduled_executor_service_bean" to "true" And I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "Unhandled exception from ScheduledTaskService" Scenario: For multiple ScheduledExecutorService beans, the one named "taskScheduler" is used Given I set environment variable "scheduled_executor_service_bean" to "true" And I set environment variable "other_scheduled_executor_service_bean" to "true" And I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "Unhandled exception from ScheduledTaskService" Scenario: For multiple TaskScheduler beans, the one named "taskScheduler" is used Given I set environment variable "custom_task_scheduler_bean" to "true" Given I set environment variable "second_task_scheduler_bean" to "true" And I run spring boot "ScheduledTaskScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "Unhandled exception from ScheduledTaskService" Scenario: Scheduled tasks execute on a ScheduledExecutorService rather than a single-threaded Executor, when available Given I set environment variable "scheduled_executor_service_bean" to "true" And I run spring boot "ScheduledTaskExecutorScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the event "metaData.executor.multiThreaded" is true diff --git a/features/scripts/assemble-fixtures.sh b/features/scripts/assemble-fixtures.sh new file mode 100755 index 00000000..9dafd461 --- /dev/null +++ b/features/scripts/assemble-fixtures.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +mkdir -p features/fixtures/libs +./gradlew bugsnag:assemble bugsnag-spring:assemble -Pversion=9.9.9-test +cp bugsnag/build/libs/bugsnag-9.9.9-test.jar features/fixtures/libs/bugsnag-9.9.9-test.jar +cp bugsnag-spring/build/libs/bugsnag-spring-9.9.9-test.jar features/fixtures/libs/bugsnag-spring-9.9.9-test.jar diff --git a/features/scripts/build-plain-spring-app.sh b/features/scripts/build-plain-spring-app.sh index 1990e8b3..d2a8d4c3 100755 --- a/features/scripts/build-plain-spring-app.sh +++ b/features/scripts/build-plain-spring-app.sh @@ -1,3 +1,6 @@ #!/usr/bin/env bash -./gradlew -p features/fixtures/mazerunnerplainspring war \ No newline at end of file +# Start Tomcat then copy a WAR file across to serve it +catalina.sh start +./gradlew -p features/fixtures/mazerunnerplainspring war +cp features/fixtures/mazerunnerplainspring/build/libs/mazerunnerplainspring.war $CATALINA_HOME/webapps/ROOT.war diff --git a/features/scripts/run-java-app.sh b/features/scripts/run-java-app.sh index 75091394..72cb3fe0 100755 --- a/features/scripts/run-java-app.sh +++ b/features/scripts/run-java-app.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash +catalina.sh stop + if [[ -z "${LOGBACK_FILE}" ]]; then rm features/fixtures/mazerunner/src/main/resources/logback.xml else mkdir features/fixtures/mazerunner/src/main/resources - sed "s#__BUGSNAG_API_KEY__#$BUGSNAG_API_KEY#g; s#__BUGSNAG_MOCK_PATH__#http://localhost:$MOCK_API_PORT#g;" \ - < "features/fixtures/logback/$LOGBACK_FILE" \ - > "features/fixtures/mazerunner/src/main/resources/logback.xml" + cp "features/fixtures/logback/$LOGBACK_FILE" "features/fixtures/mazerunner/src/main/resources/logback.xml" fi ./gradlew -p features/fixtures/mazerunner bootRun \ No newline at end of file diff --git a/features/scripts/run-java-spring-boot-app.sh b/features/scripts/run-java-spring-boot-app.sh index f97d3f52..f806fb9b 100755 --- a/features/scripts/run-java-spring-boot-app.sh +++ b/features/scripts/run-java-spring-boot-app.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash +catalina.sh stop ./gradlew -p features/fixtures/mazerunnerspringboot bootRun \ No newline at end of file diff --git a/features/session_tracking_auto.feature b/features/session_tracking_auto.feature index fa35e533..a294d692 100644 --- a/features/session_tracking_auto.feature +++ b/features/session_tracking_auto.feature @@ -2,25 +2,10 @@ Feature: Auto Session Tracking Scenario: Report automatic session from a spring boot app When I run spring boot "AutoSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the session tracking API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "sessionCounts" is an array with 1 element - And the payload field "sessionCounts.0.startedAt" is not null - And the payload field "sessionCounts.0.sessionsStarted" equals 1 - And the payload field "app" is not null - And the payload field "app.version" equals "1.0.0" - -Scenario: Report automatic session from a plain spring app - Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "true" - And I run the plain spring app - When I navigate to the route "/add-session" on port "1235" - Then I should receive a request - And the request is a valid for the session tracking API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "sessionCounts" is an array with 1 element - And the payload field "sessionCounts.0.startedAt" is not null - And the payload field "sessionCounts.0.sessionsStarted" equals 2 - # (1 session for the start-up check on "/" and the second for "/add-session") - And the payload field "app" is not null - And the payload field "app.version" equals "1.0.0" \ No newline at end of file + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Spring" notifier + And the session payload field "sessionCounts" is an array with 1 elements + And the session payload field "sessionCounts.0.startedAt" is not null + And the session payload field "sessionCounts.0.sessionsStarted" equals 1 + And the session payload field "app" is not null + And the session payload field "app.version" equals "1.0.0" diff --git a/features/session_tracking_handled.feature b/features/session_tracking_handled.feature index 913514a1..d4928f37 100644 --- a/features/session_tracking_handled.feature +++ b/features/session_tracking_handled.feature @@ -2,99 +2,90 @@ Feature: Session Tracking Scenario: Manual Session sends in plain Java app When I run "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the session tracking API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "sessionCounts" is an array with 1 element - And the payload field "sessionCounts.0.startedAt" is not null - And the payload field "sessionCounts.0.sessionsStarted" equals 1 - And the payload field "app" is not null - And the payload field "app.version" equals "1.2.3" - And the payload field "device" is not null + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Java" notifier + And the session payload field "sessionCounts" is an array with 1 elements + And the session payload field "sessionCounts.0.startedAt" is not null + And the session payload field "sessionCounts.0.sessionsStarted" equals 1 + And the session payload field "app" is not null + And the session payload field "app.version" equals "1.2.3" + And the session payload field "device" is not null Scenario: Manual Session sends in spring boot app When I run spring boot "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the session tracking API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "sessionCounts" is an array with 1 element - And the payload field "sessionCounts.0.startedAt" is not null - And the payload field "sessionCounts.0.sessionsStarted" equals 1 - And the payload field "app" is not null - And the payload field "app.version" equals "1.2.3" - And the payload field "device" is not null + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Spring" notifier + And the session payload field "sessionCounts" is an array with 1 elements + And the session payload field "sessionCounts.0.startedAt" is not null + And the session payload field "sessionCounts.0.sessionsStarted" equals 1 + And the session payload field "app" is not null + And the session payload field "app.version" equals "1.2.3" + And the session payload field "device" is not null Scenario: Manual Session sends in plain Spring app When I run plain Spring "ManualSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the session tracking API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "sessionCounts" is an array with 1 element - And the payload field "sessionCounts.0.startedAt" is not null - And the payload field "sessionCounts.0.sessionsStarted" equals 1 - And the payload field "app" is not null - And the payload field "app.version" equals "1.2.3" - And the payload field "device" is not null + And I wait to receive a session + Then the session is valid for the session reporting API version "1.0" for the "Bugsnag Spring" notifier + And the session payload field "sessionCounts" is an array with 1 elements + And the session payload field "sessionCounts.0.startedAt" is not null + And the session payload field "sessionCounts.0.sessionsStarted" equals 1 + And the session payload field "app" is not null + And the session payload field "app.version" equals "1.2.3" + And the session payload field "device" is not null Scenario: Test handled Exception with Session information in plain Java app When I run "HandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.handled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.handled" equals 1 Scenario: Test handled Exception with Session information in spring boot app When I run spring boot "HandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.handled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.handled" equals 1 Scenario: Test handled Exception with Session information in plain Spring app When I run plain Spring "HandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "HandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.handled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.handled" equals 1 Scenario: Test handled Exception with no session information in plain Java app When I run "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null Scenario: Test handled Exception with no session information in Spring Boot app When I run spring boot "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null Scenario: Test handled Exception with no session information in plain Spring app When I run plain Spring "HandledExceptionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null diff --git a/features/session_tracking_unhandled.feature b/features/session_tracking_unhandled.feature index 2c433629..116a57c5 100644 --- a/features/session_tracking_unhandled.feature +++ b/features/session_tracking_unhandled.feature @@ -2,63 +2,57 @@ Feature: Session Tracking Scenario: Test unhandled Exception with Session information in plain Java app When I run "UnhandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "UnhandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.unhandled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.unhandled" equals 1 Scenario: Test unhandled Exception with Session information in Spring Boot app When I run spring boot "UnhandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "UnhandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.unhandled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.unhandled" equals 1 Scenario: Test unhandled Exception with Session information in plain Spring app When I run plain Spring "UnhandledSessionScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "UnhandledSessionScenario" - And the payload field "events.0.session" is not null - And the payload field "events.0.session.id" is not null - And the payload field "events.0.session.startedAt" is not null - And the payload field "events.0.session.events.unhandled" equals 1 + And the error payload field "events.0.session" is not null + And the error payload field "events.0.session.id" is not null + And the error payload field "events.0.session.startedAt" is not null + And the error payload field "events.0.session.events.unhandled" equals 1 Scenario: Test unhandled exception with no session information in plain Java app When I run "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null Scenario: Test unhandled exception with no session information in Spring Boot app When I run spring boot "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null Scenario: Test unhandled exception with no session information in plain Spring app When I run plain Spring "CrashHandlerScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events" is an array with 1 elements And the event "session" is null diff --git a/features/steps/assertion_steps.rb b/features/steps/assertion_steps.rb deleted file mode 100644 index e998c37c..00000000 --- a/features/steps/assertion_steps.rb +++ /dev/null @@ -1,7 +0,0 @@ -Then("the request used the Spring notifier") do - steps %Q{ - Then the payload field "notifier.name" equals "Bugsnag Spring" - And the payload field "notifier.url" equals "https://github.com/bugsnag/bugsnag-java" - } -end - diff --git a/features/steps/build_steps.rb b/features/steps/build_steps.rb index cace88be..90cfe241 100644 --- a/features/steps/build_steps.rb +++ b/features/steps/build_steps.rb @@ -1,6 +1,6 @@ When("I run {string} with the defaults") do |eventType| steps %Q{ - And I set environment variable "MOCK_API_PATH" to "http://localhost:#{MOCK_API_PORT}" + And I set environment variable "MAZERUNNER_BASE_URL" to "http://localhost:9339/" And I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa" And I set environment variable "EVENT_TYPE" to "#{eventType}" And I run the script "features/scripts/run-java-app.sh" synchronously @@ -9,7 +9,7 @@ When("I run {string} with logback config {string}") do |eventType, logback_config| steps %Q{ - And I set environment variable "MOCK_API_PATH" to "http://localhost:#{MOCK_API_PORT}" + And I set environment variable "MAZERUNNER_BASE_URL" to "http://localhost:9339/" And I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa" And I set environment variable "EVENT_TYPE" to "#{eventType}" And I set environment variable "LOGBACK_FILE" to "#{logback_config}" @@ -19,7 +19,7 @@ When("I run spring boot {string} with the defaults") do |eventType| steps %Q{ - And I set environment variable "MOCK_API_PATH" to "http://localhost:#{MOCK_API_PORT}" + And I set environment variable "MAZERUNNER_BASE_URL" to "http://localhost:9339/" And I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa" And I set environment variable "EVENT_TYPE" to "#{eventType}" And I run the script "features/scripts/run-java-spring-boot-app.sh" synchronously @@ -28,19 +28,21 @@ Given("I run the plain spring app") do steps %Q{ - And I set environment variable "MOCK_API_PATH" to "http://#{current_ip}:#{MOCK_API_PORT}" + And I set environment variable "MAZERUNNER_BASE_URL" to "http://localhost:9339/" And I set environment variable "BUGSNAG_API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa" And I run the script "features/scripts/build-plain-spring-app.sh" synchronously - And I stop the service "plainspringapp" - And I start the service "plainspringapp" - And I wait for the app to respond on port "1235" } end When("I run plain Spring {string} with the defaults") do |eventType| steps %Q{ And I run the plain spring app - And I navigate to the route "/run-scenario/#{eventType}" on port "1235" + And I navigate to the route "/run-scenario/#{eventType}" on port "8080" } end +When(/^I navigate to the route "(.*)" on port "(\d*)"/) do |route, port| + steps %Q{ + When I open the URL "http://localhost:#{port}#{route}" + } +end diff --git a/features/support/env.rb b/features/support/env.rb index f52a5cd0..40315c98 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,25 +1,7 @@ -# Configure app environment - -require 'os' - -def current_ip - if OS.mac? - 'host.docker.internal' - else - ip_addr = `ifconfig | grep -Eo 'inet (addr:)?([0-9]*\\\.){3}[0-9]*' | grep -v '127.0.0.1'` - ip_list = /((?:[0-9]*\.){3}[0-9]*)/.match(ip_addr) - ip_list.captures.first - end +BeforeAll do + $api_key = "a35a2a72bd230ac0aa0f52715bbdc6aa" + Maze.config.enforce_bugsnag_integrity = false + Maze.config.receive_no_requests_wait = 10 + Maze.config.receive_requests_wait = 60 + Maze::Runner.run_script("features/scripts/assemble-fixtures.sh", blocking: true) end - -# Install latest versions of the notifiers and clean fixtures -run_required_commands([ - ["mkdir", "-p", "features/fixtures/libs"], - ["./gradlew", "clean", "bugsnag:assemble", "-Pversion=9.9.9-test"], - ["cp", "bugsnag/build/libs/bugsnag-9.9.9-test.jar", - "features/fixtures/libs/bugsnag-9.9.9-test.jar"], - ["./gradlew", "clean", "bugsnag-spring:assemble", "-Pversion=9.9.9-test"], - ["cp", "bugsnag-spring/build/libs/bugsnag-spring-9.9.9-test.jar", - "features/fixtures/libs/bugsnag-spring-9.9.9-test.jar"], - ["./gradlew", "-p", "features/fixtures", "clean"], -]) diff --git a/features/threads.feature b/features/threads.feature index 1656d94d..4c100f58 100644 --- a/features/threads.feature +++ b/features/threads.feature @@ -2,29 +2,28 @@ Feature: Sending java thread data Scenario: Test logback appender with the sendThreads flag set in config When I run "LogbackScenario" with logback config "threads_config.xml" - Then I should receive a request - And the request is a valid for the error reporting API - And the "Bugsnag-API-Key" header equals "a35a2a72bd230ac0aa0f52715bbdc6aa" - And the payload field "events" is an array with 1 element + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events" is an array with 1 elements And the exception "errorClass" equals "java.lang.RuntimeException" And the exception "message" equals "LogbackScenario" - And the payload field "events.0.threads" is a non-empty array + And the error payload field "events.0.threads" is a non-empty array Scenario: Test Java app with the sendThreads flag set in config When I run "ThreadsScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the payload field "events.0.threads" is a non-empty array + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier + And the error payload field "events.0.threads" is a non-empty array Scenario: Test Spring Boot app with the sendThreads flag set in config When I run spring boot "ThreadsScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the payload field "events.0.threads" is a non-empty array + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events.0.threads" is a non-empty array Scenario: Test Spring app with the sendThreads flag set in config When I run plain Spring "ThreadsScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API - And the payload field "events.0.threads" is a non-empty array + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier + And the error payload field "events.0.threads" is a non-empty array diff --git a/features/user.feature b/features/user.feature index c8226883..bc8f17d0 100644 --- a/features/user.feature +++ b/features/user.feature @@ -2,8 +2,8 @@ Feature: Reporting User Information Scenario: Override user details in callback in Java app When I run "UserCallbackScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Java" notifier And the exception "message" equals "UserCallbackScenario" And the event "user.id" equals "Agent Pink" And the event "user.email" equals "bob@example.com" @@ -11,8 +11,8 @@ Scenario: Override user details in callback in Java app Scenario: Override user details in callback in Spring Boot app When I run spring boot "UserCallbackScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "UserCallbackScenario" And the event "user.id" equals "Agent Pink" And the event "user.email" equals "bob@example.com" @@ -20,8 +20,8 @@ Scenario: Override user details in callback in Spring Boot app Scenario: Override user details in callback in Spring app When I run plain Spring "UserCallbackScenario" with the defaults - Then I should receive a request - And the request is a valid for the error reporting API + And I wait to receive an error + And the error is valid for the error reporting API version "4" for the "Bugsnag Spring" notifier And the exception "message" equals "UserCallbackScenario" And the event "user.id" equals "Agent Pink" And the event "user.email" equals "bob@example.com" diff --git a/gradle.properties b/gradle.properties index 56ad87b6..24d93332 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=3.6.3 +version=3.6.4 group=com.bugsnag # Default properties