Skip to content

Commit

Permalink
Merge pull request #2274 from particle-iot/ch71862/startup-minimum-ra…
Browse files Browse the repository at this point in the history
…m-slo

Develop PoC for device-os-test-runner tool to validate minimum RAM SLO is achieved
  • Loading branch information
Joe Goggins authored Feb 5, 2021
2 parents fdc2df8 + 97a2c0d commit 89106d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions user/tests/integration/startup-slos/startup-slos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "application.h"
#include "test.h"

test(slo_startup_stats)
{
Particle.connect();
waitUntil(Particle.connected);
uint32_t free_mem = System.freeMemory();
String stats = String::format("{\"free_mem\": %u }", free_mem);
Particle.publish("startup_stats", stats);
}
26 changes: 26 additions & 0 deletions user/tests/integration/startup-slos/startup-slos.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
suite('Device startup service level objectives (SLOs)');

// intentionally omit `platform('...');` this test is relevant to ALL Particle platforms

test('slo startup stats', async function () {
const unparsedJson = await this.particle.receiveEvent('startup_stats');
const startupStats = JSON.parse(unparsedJson);

///
// Assertions against the minimum RAM SLO
///
const minimumRAMTargetDefault = 60000;
const minimumRAMTargetForPhotonAndP1 = 45000;
let target = minimumRAMTargetDefault;

// make exceptions on target for photon/p1
const dut = this.particle.devices[0]; // see device-os-test-runner for documentation
if (dut.platform.name == 'photon' || dut.platform.name == 'p1') {
target = minimumRAMTargetForPhotonAndP1;
}
// show actuals first before assertions
console.log(`actual_free_mem=${startupStats.free_mem} target_free_mem=${target} platform=${dut.platform.name}`);

// make free ram assertion
expect(startupStats.free_mem).to.be.at.least(target);
});

0 comments on commit 89106d9

Please sign in to comment.