13 Commits

Author SHA1 Message Date
Lubomir Rintel
f7c8597835 test/cloud-meta-mock: do not print what we listen on if we got a FD
This message is useless for non-interactive use and clobbers over
otherwise very appealing test output.

The callers knows what we're going to listen on, it passed us the file
descriptor.
2025-01-20 14:08:12 +01:00
Thomas Haller
28a1afca63 python: reformat with black-23.7.0-2.fc39.noarch
The base image for the "check-tree" test got bumped to Fedora 39.  This
brings a new python-black version (23.7.0 vs. 22.8.0) and requires
reformatting.

Maybe we should stick to 22.8.0, via `pip install`. But it seems better
to just follow the latest black version (the one from current Fedora).

So do the reformatting instead.

https://black.readthedocs.io/en/stable/change_log.html#id38
2023-12-06 11:56:11 +01:00
Thomas Haller
ddcb396495 tests: avoid Python3 f-string in "test-cloud-meta-mock.py"
It breaks tests on Debian:9, which use Python2 still.

Fixes: e1f3acf3a6 ('test-cloud-meta-mock: allow configuring the provider that are mimicked')
2023-06-28 12:14:21 +02:00
Thomas Haller
e1f3acf3a6 test-cloud-meta-mock: allow configuring the provider that are mimicked
"test-cloud-meta-mock.py" needs to be mocked, so it only replies
to stuff that we tell it to. Except for the API token, that is
pushed by the client.

We need to be able to tell the mock whether it supports that API
or not. By default it does, but by setting "/.nmtest/providers"
we can limit that.

The DEFAULT_RESOURCE are now grouped by provider. If a path is not
explicitly mocked, we may fallback to the DEFAULT_RESOURCE, but only if
the respective "/.nmtest/providers" is enabled and if /.nmtest/allow-default"
indicates so (which they do by default).
2023-05-22 17:26:10 +02:00
Thomas Haller
4691f45bde test-cloud-meta-mock: add and use helper to send response code 2023-05-22 17:24:55 +02:00
Thomas Haller
77fd4d5f0e test-cloud-meta-mock: update default MAC address for test-cloud-meta-mock.py
Choose a MAC address that is easily recognizable. And where you can
see which is mac1 and mac2.
2023-05-22 17:24:55 +02:00
Lubomir Rintel
c72e085f5c test/cloud-meta-mock: mock GCP metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel
5b5ef08aee test/cloud-meta-mock: mock azure metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel
620a737cb7 test/cloud-meta-mock: mock aliyun metadata API
Not used for testing, but still might be useful for development.
2023-05-12 12:42:55 +02:00
Lubomir Rintel
41f0f6fec8 test/cloud-meta-mock: allow putting the resources
This reworks the cloud metadata mock server in a significant way.

Most importantly this makes it possible for the client to add and
modify the resources for later retrieval using the PUT method.
This allows the test to create the fixture for itself.

The default set of resources is still provided, so that the too remains
useful as a development aid. If that is not desirable, the --empty
parameter might be passed to cause the server to start with no
resources.
2023-05-12 12:42:55 +02:00
Lubomir Rintel
2e8ff9f8a0 Revert "client/tests: don't do dup2() dance to pass file descriptor to "tools/test-cloud-meta-mock.py""
This changed the fd passing protocol making it not compatible with
systemd-socket-activate(1).

This reverts commit 342ee618c7.
2023-05-12 12:42:54 +02:00
Thomas Haller
342ee618c7 client/tests: don't do dup2() dance to pass file descriptor to "tools/test-cloud-meta-mock.py"
"preexec_fn" is not great, because it is not generally safe in multi
threaded code (and we don't know whether the test didn't start other
threads already, like a GDBus worker thread). Well, it probably is safe,
if you only call async signal safe code, but it's not clear what os.dup2()
does under the hood.

Just avoid that. We can pass on the FD directly.
2023-03-30 15:36:16 +02:00
Lubomir Rintel
1e114c804b tools/test-cloud-meta-mock: add a mock metadata server for cloud-setup
Useful for testing/development.
2023-03-21 23:35:42 +01:00