balena-os / leviathan

A distributed hardware testing framework
https://balena-os.github.io/leviathan
Apache License 2.0
23 stars 6 forks source link

Fix fetchOS behavior for balena-staging environment #465

Open vipulgupta2048 opened 3 years ago

vipulgupta2048 commented 3 years ago

Was having this issue for some time now, my config looks like this.

    {
        deviceType: "raspberrypi3",
        suite: `${__dirname}/../suites/os`,
        config: {
            networkWired: false,
            networkWireless: true,
            downloadVersion: 'latest',
            interactiveTests: false, // redundant
            balenaApiKey: 'some-other-key',
            balenaApiUrl: 'balena-staging.com',
            organization: 'some-app'
        },
        image: `${__dirname}/balena.img`,
        workers: {
            balenaApplication: 'testbot-some',
            apiKey: "some-key",
        }
    },

And, when I run the HUP suite, I was getting the error

[2021-08-10T06:28:23.464Z][-hup] Fetching balenaOS version 2021.01.0.dev, attempt 1...

[2021-08-10T06:28:24.555Z][-hup] (node:79) UnhandledPromiseRejectionWarning: Error: No such version for the device type

Didn't understand what was going wrong until I realized the shaky logic we have here which I assume breaks for when the environment is balena-staging since the API returns ESR releases for raspberrypi3 device type

https://github.com/balena-os/leviathan/blob/e89420826aae5a66043838b63d4dd0d9e851ce44/core/lib/components/balena/sdk.js#L610-L617

vipulgupta2048 commented 3 years ago

@thgreasi recommended filtering the ESR releases out to only give us accurate versions. Check this out future Vipul https://github.com/balena-io/resin-site/pull/1324/files#diff-f6d3112363434753ed4b6cbbb9b04db48cc012fd5b45ecd0b69130dbe63a477bR136