Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add artifacts support #1189

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions client/lib/config-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ async function testConfig(configs) {
for (const config of configs) {
const balenaCloud = new BalenaCloudInteractor(config.config.balenaApiUrl);
const balena = await balenaCloud.authenticate(config.config.balenaApiKey);

/**
* Don't test configs if dev mode is true in config.js
* This is useful when developing tests for a new device not on production.
*
*
* TO DISABLE VALIDATION, add the following to config.js
*
*
* debug: {
* dev: true // boolean (true/false)
* }
*/
*/
if (config.debug.dev === true ) {
console.log(`Dev mode is enabled. Skipping config ${counter} from config.js file ... 👍`)
return "notest"
Expand Down Expand Up @@ -60,6 +60,18 @@ async function testConfig(configs) {
report.verdict = false
}

// artifact path exists?
try {
if (config.artifacts) {
fs.accessSync(`${__dirname}/../suites/${config.artifacts}`, fs.F_OK);
console.log(`Artifacts path exists: ${config.suite} ✅`)
}
} catch (e) {
console.log(`Tests not found: ${e.message} ❌`)
report.errors.push({ artifact: `Artifacts not found in the suites/ folder, check path. ${e.message}` })
report.verdict = false
}

// Add new config validation tests here
// try {
// Condition to be checked
Expand Down
3 changes: 3 additions & 0 deletions client/lib/schemas/multi-client-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const innerSchema = {
image: {
type: ['string', 'boolean'],
},
artifacts: {
type: 'string',
},
workers: {
oneOf: [
{
Expand Down
1 change: 1 addition & 0 deletions docker-compose.client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- BALENAMACHINE_API_KEY=${BALENAMACHINE_API_KEY}
- BALENAMACHINE_API_URL=${BALENAMACHINE_API_URL}
- ENVIRONMENT=${ENVIRONMENT}
- ARTIFACTS=${ARTIFACTS}
depends_on:
- core

Expand Down
1 change: 1 addition & 0 deletions documentation/config-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Information on properties in `config.js`:
- **`balenaApiUrl`** is the balenaCloud environment you are targetting for your test suite. Production is `'balena-cloud.com'` and staging is `'balena-staging.com'`.
- **`organization`** is the balenaCloud organization where test applications are created for the cloud suite. Add the `username` of the user who owns the `balenaApiKey` - otherwise it will lead to authentication errors. You can find the `username` of the user from the top right section of the dashboard.
- **`debug`** is where debugging properties are stored for test runs. Check out {@page Debugging tests in Leviathan | Debugging documentation} for features you can add.
- **`artifacts`** In the event if an artifact needs to be sent to the worker, depending on the device type then use the `artifacts` property to explicitly specify which folder/file needs to be sent. These artifacts must be in the `suites` directory - so you must copy them into suites before. Optional.
- **`image`** is the absolute path to the balenaOS image that is flashed onto the Device Under Test (DUT). As shown in the example above, `${__dirname}` expands to the absolute path of the `workspace` directory, so you can use it to specify a path relative to `workspace`.

Make sure to rename the image to balena.img. If you provide `balena.img` as your balenaOS image, then Leviathan will compress it for you in `gz` format on runtime. We recommend compressing beforehand, as it saves time. For any reason if your tests download an image already and you don't want to upload an image, then set the `image` property to `false` in config.js. Be sure to set `image` to a boolean `false` without a quotes.
Expand Down
8 changes: 8 additions & 0 deletions suites/e2e/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ module.exports = {
// Configure OS image
await this.os.configure();

if(this.suite.options.artifacts !== undefined){
// extra artifacts "artifacts" are defined in the config.js of the suite
// these artifacts must be in the "suites" directory in the config.js - so you must copy them into suites before
// running the tests if these are build time artifacts
console.log(`Sending extra artifact folder: ${this.suite.options.artifacts} to worker...`)
await this.worker.sendFile(`${__dirname}/${this.suite.options.artifacts}`,'/data/', 'worker');
}

// Retrieving journalctl logs - Uncomment if needed for debugging
// Overkill quite frankly, since we aren't testing the OS and if testbot fails e2e
// suite due to h/w issues then archiveLogs will block suite teardown frequently
Expand Down
Loading