Commit Graph

4224 Commits

Author SHA1 Message Date
Christina Ying Wang
f586b7c9a8 Make dbus module side-effect free to not interfere with unit tests
When code that is unit tested is part of a file that imports modules which
depend on the dbus module, this breaks the unit test environment because there
is no system socket set up, as the unit test mocha config doesn't import fixtures.ts.

For example, if we change src/compose/utils to import device-config or api-binder, both
of those modules import lib/dbus which invokes a dbus.getBus call at the root level. This
is problematic for unit testing.

We can get around the root-level dbus.getBus call by initializing dbus only when it's first
needed. The mocked-dbus test setup code can also be removed in favor of legacy mocha
hooks, which makes the dbus stubbing in the legacy test environment more clear.
We can remove these legacy hooks when all the legacy tests are migrated to unit/integration.

Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:27:19 -07:00
Christina Ying Wang
966d957465 Convert common.js to TypeScript
Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:27:19 -07:00
Christina Ying Wang
f77fcb9ac9 Move messages.ts to device-api
Messages are all related to Supervisor API

Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Christina Ying Wang
71b2aea0fe Use v2 router directly instead of through application manager
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Christina Ying Wang
ce5bf89dfc Move /v1 routes in deviceState.router to v1.ts
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Christina Ying Wang
a2d9af2407 Move /v1 routes in apiBinder.router to v1.ts
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Christina Ying Wang
d08f25f0a3 Consolidate API middlewares, move api-keys to device-api
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Christina Ying Wang
5af146ec4e Move supervisor-api.ts to device-api/index.ts
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-10-18 14:16:53 -07:00
Balena CI
b7c497cc65
v14.2.12 2022-10-18 14:01:33 +00:00
bulldozer-balena[bot]
a3ed8dc703
Merge pull request #2034 from balena-os/device-state-tests
Migrate device-state tests to integration
2022-10-18 14:00:13 +00:00
pipex
a1e432f4fa Add build util to automatically detect arch from uname
This will help running `test:env` and `test:compose` in environments
other than `amd64`.
2022-10-17 11:32:47 -03:00
Felipe Lalanne
819e184095 Setup environment for dbus tests
Change-type: patch
2022-10-17 11:24:15 -03:00
pipex
97ec2a4151 Remove unused code from dbus module 2022-10-17 10:15:36 -03:00
pipex
4de816d1e9 Fix bug in preloading config vars 2022-10-17 10:15:36 -03:00
Balena CI
55285e9918
v14.2.11 2022-10-17 12:08:25 +00:00
bulldozer-balena[bot]
7297b74a2d
Merge pull request #2000 from balena-os/accept_more_label_chars
Allow most printable ASCII chars for service label key
2022-10-17 12:07:06 +00:00
Ken Bannister
91f93952db Allow most printable ASCII chars for service label key
Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-10-14 20:50:25 -04:00
Balena CI
eec12faa02
v14.2.10 2022-10-13 16:09:18 +00:00
bulldozer-balena[bot]
a57f02cf63
Merge pull request #2031 from balena-os/inherited-secrets
Use inherited secrets for flowzone
2022-10-13 16:08:01 +00:00
Balena CI
076d95d0d2
v14.2.9 2022-10-10 19:42:06 +00:00
bulldozer-balena[bot]
dfcaa2ecb8
Merge pull request #2035 from balena-os/parallel-start
Start state engine and API binder in parallel
2022-10-10 19:40:51 +00:00
Pagan Gazzard
080d112f3e Use inherited secrets for flowzone
Change-type: patch
2022-10-07 21:04:50 +00:00
Balena CI
ef0dcc39dc
v14.2.8 2022-10-03 20:37:37 +00:00
bulldozer-balena[bot]
6466fcbb8c
Merge pull request #2036 from balena-os/update-type-deps
Update type dependencies
2022-10-03 20:36:07 +00:00
Pagan Gazzard
0237bd7cf4 Update type dependencies
Change-type: patch
2022-10-03 14:38:42 -05:00
Felipe Lalanne
b4514631b1 Start state engine and API binder in parallel
The state engine and preloading is performed before the device gets a
chance to register, while this is desirable for preloaded apps, it
introduces a delay on registration which is known to cause issues since
the VPN is also trying to connect at the same time.

This triggers a simultaneous start of the device engine, the API binder
and the supevisor API to avoid delays.

Change-type: patch
2022-09-30 19:38:10 +00:00
Balena CI
24fafd6e9d
v14.2.7 2022-09-28 15:37:47 +00:00
bulldozer-balena[bot]
7b1c1882c0
Merge pull request #1998 from balena-os/test-refactor
Refactor (part of) the test suite into unit/integration
2022-09-28 15:36:24 +00:00
Felipe Lalanne
6ecff9d5b4 Remove blink tests
Blink tests really are testing functionality of the dependency and not
any local behavior.
2022-09-28 10:37:41 -03:00
Felipe Lalanne
209b409129 Migrate contract test to integration 2022-09-28 10:37:41 -03:00
Felipe Lalanne
1867b74bd7 Migrate config module tests to integration
This commit also changes the test:integration command to run integration
tests as different processes. This allows to avoid any test leaking into
each-other because of the use of singletons. This however has the side
effect of tests being slower, but that is a forcing function to refactor
the code.
2022-09-28 10:37:41 -03:00
Felipe Lalanne
f835db9509 Migrate legacy db test to integration folder 2022-09-28 10:37:41 -03:00
Felipe Lalanne
f19f70d690 Migrate update-lock tests as integration tests
Update-lock tests now use the actual filesystem for testing, instead of
relying on stubs and spies.

This commit also fixes a small bug with update-lock that would cause a
`PromiseRejectionHandledWarning` when the lock callback would throw.
2022-09-28 10:37:41 -03:00
Felipe Lalanne
0fb1de2a1a Migrate tests for image manager 2022-09-28 10:37:41 -03:00
Felipe Lalanne
b81294431e Migrate compose/app and compose/app-manager tests
compose/app is run as part of the unit test suite
compose/application-manager is run as part of the integration test suite
2022-09-28 10:37:41 -03:00
Felipe Lalanne
a69fbf6eac Migrate volume-manager tests to integration
Now the tests are ran against the actual docker engine instead of
against mockerode.

The new tests actually caught a bug in
`volumeManager.removeOrphanedVolumes`, where that function would try to
remove volumes for stopped containers, causing an exception.
This commit also fixes that bug.
2022-09-28 10:37:41 -03:00
Felipe Lalanne
18c2f8cec9 Migrate lib/legacy tests to integration tests
This also sets up a dbus container as part of the test environment. This
container exposes a socket that the sut container can use
2022-09-28 10:37:41 -03:00
Felipe Lalanne
a4da25c1ef Disable logs globally using mocha hooks 2022-09-28 10:37:41 -03:00
Felipe Lalanne
a5a24e6462 Split compose/service tests into unit/integration 2022-09-28 10:37:41 -03:00
Felipe Lalanne
cdc9868d29 Split compose/network test in unit/integration
Integration tests are ran in the engine instead of mockerode.
2022-09-28 10:37:40 -03:00
Felipe Lalanne
4113dde45d Split compose/volume tests into unit/integration
This also needs to modify the test environment as database migrations
will look for `config.json` in the location given by the variable
`CONFIG_MOUNT_POINT`.

The volume tests now run against the actual docker engine setup via dind

Change-type: patch
2022-09-28 10:37:40 -03:00
Felipe Lalanne
7833fa1ff3 Un-skip fs-utils test 2022-09-28 10:37:40 -03:00
Felipe Lalanne
a2f9ea17c3 Update mocha-pod to 0.8.x
Newer mocha-pod allows to setup testfs instances at the global
level. This helps the test suite setup as it can guarantee that certain
files will always be available.
2022-09-28 10:37:40 -03:00
Balena CI
dee8680779
v14.2.6 2022-09-28 00:21:07 +00:00
bulldozer-balena[bot]
4863303270
Merge pull request #2033 from balena-os/knex-bug-2032
Fix migrations hardcode to work with knex 0.95.15
2022-09-28 00:19:49 +00:00
Felipe Lalanne
bf0d9ee836 Fix migrations hardcode to work with knex 0.95.15
The latest upgrade of knex broke the webpack loader that hardcodes the
migration paths in the built code, that cause supervisors 14.2.3 to
14.2.5 (inclusive) to break anytime migrations needed to be ran (see linked issue).

This commit fixes the loader to work with the included knex version.

Relates-to: #2032
Change-type: patch
2022-09-27 19:28:32 -03:00
Balena CI
e1b12c28fe
v14.2.5 2022-09-27 04:50:53 +00:00
bulldozer-balena[bot]
bbcabc3bdc
Merge pull request #2029 from balena-os/docs/clarify-testing-after-updates
Add test troubleshooting case that appears after upgrading system
2022-09-27 04:49:39 +00:00
Christina Ying Wang
c6d5ad7a89 Add test troubleshooting case that appears after upgrading system
The error may be something to the effect of `failed to add the host
(vethd6242de) <=> sandbox (veth8e47b1a) pair interfaces: operation not supported`.

Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-09-26 20:05:53 -07:00
Balena CI
1e84f8f59f
v14.2.4 2022-09-26 20:17:29 +00:00