Skip to content

Add CPU/System metrics tests #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: next
Choose a base branch
from
8 changes: 4 additions & 4 deletions .buildkite/pipeline.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ steps:
#
# Upload all full pipelines
#
- label: ":pipeline_upload: Full browser pipeline"
timeout_in_minutes: 2
commands:
- buildkite-agent pipeline upload .buildkite/browser-pipeline.full.yml
# - label: ":pipeline_upload: Full browser pipeline"
# timeout_in_minutes: 2
# commands:
# - buildkite-agent pipeline upload .buildkite/browser-pipeline.full.yml

- label: ":pipeline_upload: Full react native pipeline"
timeout_in_minutes: 2
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ steps:
#
# Upload each basic pipeline
#
- label: ":pipeline_upload: Basic browser pipeline"
timeout_in_minutes: 2
commands:
- buildkite-agent pipeline upload .buildkite/browser-pipeline.yml
# - label: ":pipeline_upload: Basic browser pipeline"
# timeout_in_minutes: 2
# commands:
# - buildkite-agent pipeline upload .buildkite/browser-pipeline.yml

- label: ":pipeline_upload: React Native pipeline"
timeout_in_minutes: 2
Expand Down
2 changes: 1 addition & 1 deletion bin/generate-react-native-fixture
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function installCocoaPerformance() {
const podfilePath = resolve(fixtureDir, 'ios/Podfile')
let podfile = fs.readFileSync(podfilePath, 'utf8')

const performancePod = `pod 'BugsnagPerformance'`
const performancePod = `pod 'BugsnagPerformance', :git => 'https://github.com/bugsnag/bugsnag-cocoa-performance.git', :branch => 'next'`
const targetSection = 'target \'reactnative\' do'

podfile = podfile.replace(targetSection, `${targetSection}\n ${performancePod}`)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ x-common-environment: &common-environment
MAZE_BUGSNAG_API_KEY:
MAZE_APPIUM_BUGSNAG_API_KEY:
MAZE_NO_FAIL_FAST:
NATIVE_INTEGRATION:
RCT_NEW_ARCH_ENABLED:

services:
license-finder:
Expand Down Expand Up @@ -102,9 +104,7 @@ services:
<<: *common-environment
BITBAR_USERNAME:
BITBAR_ACCESS_KEY:
RCT_NEW_ARCH_ENABLED:
REACT_NATIVE_NAVIGATION:
NATIVE_INTEGRATION:
MAZE_REPEATER_API_KEY: "${MAZE_REPEATER_API_KEY_RN:-}"
ports:
- "9000-9499:9339"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ @implementation ScenarioLauncher
config.autoInstrumentAppStarts = NO;
config.autoInstrumentViewControllers = NO;
config.autoInstrumentNetworkRequests = NO;
config.autoInstrumentRendering = YES;
config.enabledMetrics.cpu = YES;
config.enabledMetrics.memory = YES;
config.enabledMetrics.rendering = YES;
config.internal.autoTriggerExportOnBatchSize = 1;

[BugsnagPerformance startWithConfiguration:config];
Expand Down
8 changes: 7 additions & 1 deletion test/react-native/features/native-integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ Feature: Native Integration
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" double array attribute "custom.doublearray.attribute" equals the array:
| 1.1 |
| 2.2 |
| 3.3 |
| 3.3 |

# Device metrics
And the "Native child span" span has int attribute named "bugsnag.system.memory.spaces.device.size"
And the "Native child span" span has int attribute named "bugsnag.system.memory.spaces.device.mean"
And the "Native child span" span has array attribute named "bugsnag.system.memory.spaces.device.used"
And the "Native child span" span has array attribute named "bugsnag.system.memory.timestamps"
14 changes: 14 additions & 0 deletions test/react-native/features/steps/react-native-steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
end
end

Then('the {string} span has {word} attribute named {string}') do |span_name, attribute_type, attribute|
spans = spans_from_request_list(Maze::Server.list_for('traces'))
found_spans = spans.find_all { |span| span['name'].eql?(span_name) }
raise Test::Unit::AssertionFailedError.new "No spans were found with the name #{span_name}" if found_spans.empty?
raise Test::Unit::AssertionFailedError.new "found #{found_spans.size} spans named #{span_name}, expected exactly one" unless found_spans.size == 1

attributes = found_spans.first['attributes']
attribute = attributes.find { |a| a['key'] == attribute }

value = attribute&.dig 'value', "#{attribute_type}Value"

Maze.check.not_nil value
end

When("I relaunch the app after shutdown") do
max_attempts = 20
attempts = 0
Expand Down