21 Commits

Author SHA1 Message Date
Maciej Borzecki
02116ef645 dbusutil/netplantest: add way to sync, and sync access to exported API objects
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-16 11:59:54 +02:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Michael Vogt
b0ab8e62c8 dbusutil: move debian patch into dbustest
Newer version of go-dbus send `AUTH TEST` to the dbus test code
instead of the previous `AUTH TEST TEST`. This broke unit tests
in debian-sid and got distro patched in sid. The main snapd code
will need to get this change eventually too so integrate it now
and handle both the old and new godbus auth.
2022-07-27 15:54:18 +02:00
Miguel Pires
615da7771d many: fix failing golangci checks
* Group 3rd party imports
* Remove unused vars
* Move var only used in tests into test
* Add 'nolint' to ignore warning on unused iotas (might've been
left to improve readability).
2022-02-09 10:12:09 +00:00
Michael Vogt
c972b1e663 coreconfig: cleanup/improve netplan error reporting/add more tests 2021-12-16 18:22:33 +01:00
Michael Vogt
cedb71736a Merge remote-tracking branch 'upstream/master' into netplan-read-write 2021-11-04 13:02:16 +01:00
Maciej Borzecki
c8b9e2d753 dbusutil/dbustest: drop unnecessary comment
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-10-06 11:33:18 +02:00
Maciej Borzecki
dd25ffe289 dbusutil/dbustest: tweak comments
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-09-30 10:51:49 +02:00
Maciej Borzecki
44483540b9 dbusutil/dbustest: make closed flag atomic, refactor write
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-09-30 09:54:48 +02:00
Maciej Borzecki
f7f4f8f210 dbusutil/dbustest: use channels for synchronization
The condition/lock/shared buffer thingy was failing when running tests with
-count=100 due to proper lack of serialization. Refactor the code to use
channels, such that it is simpler to follow.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-09-29 16:07:12 +02:00
Maciej Borzecki
5d70da39f1 dbusutil/dbustest: lock the output buffer
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-09-29 15:34:25 +02:00
Maciej Borzecki
5de9865b2f sandbox/cgroup: wait for start transient unit job to finish
The snap binary calls appropriate systemd instance to start a transient unit
that wraps the scope of the snap application. The code used to implement a busy
loop, checking whether the current process has been moved to new unit. However,
we should actually implement a complete job handlign sequence like systemd-run
does, that it wait for JobRemoved signal that matches our create transient unit
request.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-09-29 12:01:22 +02:00
Michael Vogt
c05fdb7d5e Merge remote-tracking branch 'upstream/master' into netplan-read-write 2021-09-09 09:37:58 +02:00
Michael Vogt
7f444c3f2a netplantest: move under dbusutil 2021-09-07 16:19:11 +02:00
James Henstridge
ba547a653f dbusutil: extract helper for creating private session bus connection 2020-12-21 10:43:20 +08:00
Zygmunt Krynicki
ee0ed9b1ab dbustest: fix stale comment references
The two mock helpers have a bit longer names.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2020-09-29 11:03:34 +02:00
Zygmunt Krynicki
a8765f5083 dbusutil/dbustest: add separate license from package
This makes go doc not think that the GPL license is the documentation.
Thanks to Samuele for spotting.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2020-06-08 15:25:50 +02:00
Zygmunt Krynicki
3cd07ec14a dbusutil: use kinder language
Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>
2020-06-01 19:50:07 +02:00
Zygmunt Krynicki
0a87424476 dbusutil: remove need for syscall
I wasn't aware of the various os.ModeFoo constant's and that they are
sufficient to probe for sockets. Thanks Maciek!

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2020-06-01 11:19:48 +02:00
Zygmunt Krynicki
9483501739 dbusutil: move all D-Bus helpers and D-Bus test helpers
This commit is squashed history taken out of the refresh-app-awareness-v2
branch. It aggregated most of the new D-Bus helper logic in a pair of
packages. The dbusutil package contains non-silly logic to connect
to the session and system bus, as well as public mocking helpers.
The dbustest sub-package contains two helpers that provide dbus.Conn
for testing interaction and for testing bus access.

Note that I chose to leave behind one file in testutils, as it contains
existing test code used by user agent code. I can do that in another pass
to isolate it from this move.

This code is used in feature/refresh-app-awareness-v2, for both the
existing code in "snap run" and the new code in sandbox/cgroup package.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2020-05-29 15:17:43 +02:00