5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-21 17:33:48 +03:00
Commit Graph

66 Commits

Author SHA1 Message Date
Fiona Ebner
903d285751 test: have lock file test use run_fork() helper
There are differences for error handling in the old and new helper, in
particular when the child is signaled. But the test here does not
explicitly check for specific error conditions or messages and is
therefore still correct with the new helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Fiona Ebner
de6ffbdebf test: lock file: get rid of END block that made test always pass
The exit code of the test would be the exit code of the 'rm' system
call, no matter if the test itself failed or not. Use an eval block
instead of the END block and propagate the error correctly.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-11-14 20:44:53 +01:00
Wolfgang Bumiller
b518bbd5f9 interfaces: support stanzas without types/methods
This is allowed in ifupdown2 and previously interfaces named
'vmbr\d+' were recognized as bridges even if they used this mode.
With commit e68ebda4f1 this is no longer the case.

Fixes: e68ebda4f1 ("fix #545: interfaces: allow arbitrary bridge names in network config")
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-23 15:19:43 +02:00
Fabian Grünbichler
f869c96a94 network tests: test #5141
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-01-03 12:18:26 +01:00
Fabian Grünbichler
e8c1bbfca2 network tests: switch to ifupdown2
adapt allow-* to auto, and drop the one test where behaviour is not testable
anymore.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-01-03 12:14:43 +01:00
Thomas Lamprecht
7ccdc805e3 section config: avoid unamed boolean parameter use hash
Even with just one param it's extra work to check what it refers too,
with named ones in a hash one hasn't that issue even with many params.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 09:58:01 +01:00
Dominik Csapak
7d6cc4f14f section config: add tests for separated property lists
more or less a copy from the normal section config test, but now with
properties defined multiple times as well as conflicting options

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: improve consistency with property-isolation terminology ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 09:57:39 +01:00
Dominik Csapak
15645af168 tools: add is_deeply
to compare nested hashes/lists and scalar values recursively.
Also includes some tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 09:24:09 +01:00
Dominik Csapak
e42f1dd6a1 section config: add test for the schemas
by simply doing an 'is_deeply' on the generated schema with
the current generated schema

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 09:24:09 +01:00
Fiona Ebner
9c357928ef test: section config: also test array entries in unknown section
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-08-16 11:25:13 +02:00
Dominik Csapak
d2a6411cab SectionConfig: fix handling unknown sections
if we're parsing an unknown section, we cannot check the schema with
`is_array` to check if it's an array type or not, thus we have to
handle that separately.

fix this by handling data in unknown sections like an array similar to
"cb2646c7b4974e33f4148752deec71f0d589b0f3" in proxmox-section-config.
This way we can write unknown section out again like we parsed it.

Add a regression test for an unknown field not in the schema.

This fixes an issue, where calling `qm destroy ID --purge` removed much
of the configs ob backup jobs (since there we parse an 'unknown' section
and run into the `is_array` error)
(Reported in the forum: https://forum.proxmox.com/threads/132091)

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-08-16 11:19:26 +02:00
Dominik Csapak
69d9edcc75 section config: implement array support
enables section configs in the style of:

----
type: id
    property value
    property value2
    property value3
----

can be combined with property strings

the provided create and update schema just pass through the array type
to the api, so the api call must always contain the complete array

also adds a test case for such array fields

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-06-07 13:50:51 +02:00
Dominik Csapak
07f136d636 JSONSchema: add support for array parameter in api calls, cli and config
a few things were missing for it to work:
* on the cli, we have to get the option as an array if the type is an
  array
* the untainting must be done recursively, otherwise, the regex matching
  converts an array hash into the string 'ARRAY(0x123412341234)'
* JSONSchema::parse_config did not handle array formats specially, but
  we want to allow to specify them multiple time
* the biggest point: in the RESTHandler, to be compatible with the
  current gui behavior, we have to rewrite two parameter types:
  - when the api defines a '-list' format for a string type, but we get
    a list (because of the changes in http-server), we join the list
    with a comma into a string
  - when the api defines an 'array' type, but we get a scalar value,
    wrap the value in an array (because for www-form-urlencoded, you
    cannot send an array with a single value) add tests for this
    behavior, some of which we want to deprecate and remove in the
    future

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-06-07 13:10:50 +02:00
Fabian Grünbichler
7a48f55a8f fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-10 12:25:54 +01:00
Thomas Lamprecht
8b7b0cc5fe tests: section config: comment need for warn on debugging
as often only warn really makes it out of perl/our pit of std out/err
handling (e.g., I had a case where neither print STDERR nor syslog
worked, but warn did)

also, the tests are rather brittle w.r.t their expect_fail variant,
as the actual expected error should be enforced.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-13 11:54:34 +01:00
Wolfgang Bumiller
85bc5755c0 add section config tests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-12 15:41:50 +01:00
Dominik Csapak
9572e1046b CalendarEvent: use rust implementation
by replacing the parsing code and 'compute_next_event' by their
PVE::RS::CalendarEvent equivalent

adapt the tests, since we do not have access to the internal structure
(and even if we had, it would be different) and the error messages
are different

the 'compute_next_event' and parsing tests still pass though

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-01-13 14:50:47 +01:00
Thomas Lamprecht
0dc7fd7b50 inotify: network: improve "allow-hotplug" & "auto" interaction
commit c86cfb8bbd dropped allow-hotplug
from the primary interfaces file completely on write, but that breaks
setups that come from plain Debian.

Instead, as stop-gap measurement, transform "allow-hotplug" to auto
in the PVE controlled config.

That avoids conflict and improves installing PVE on top of plain
Debian, as the interface still comes up after the first reboot.

But it is not ideal auto is not the same as hotplug, so we need to
also track that difference in the future, but that needs some
adaptions in the API too (change autostart from boolean to
string+enum or so=

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-29 09:57:59 +02:00
Thomas Lamprecht
89075c3505 test: import JSON for quicker debugging
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-24 12:56:09 +02:00
Fabian Grünbichler
4d22a9729d tests: run with static TZ value
else tests may randomly fail depending on which local TZ is set..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-05-19 18:08:36 +02:00
Stefan Reiter
4997835b08 format: handle undef, 0, and decimals in render_duration
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-02-08 14:40:38 +01:00
Stefan Reiter
57b3385290 extract PVE::Format from PVE::CLIFormatter for reuse
and add some tests

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-02-08 14:40:38 +01:00
Dominic Jäger
e37d592413 Add tests for verify_configid
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2020-10-29 15:20:40 +01:00
Alexandre Derumier
fe2a773cd0 Inotify: write_network_interfaces : always autostart bond slaves interfaces
Currently, bond slaves are mostly working without autostart,
because bond slaves scripts from ifupdown1 && also ifupdown2
 have some kind of hacks to start the slaves.

But if users want to do some tuning on the ifaces, they are not applied.

Also, with ifupdown2 + ovs, this kind of hack is not implemented (yet), so the
slaves of the bond are still down.

Debian/Ubuntu official docs always set "auto ethX" for bond slaves,
it's really more clean like this.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-06-08 17:34:57 +02:00
Alexandre Derumier
e1b784f36e t.list-interfaces.pl: add cidr address test
also reuse wanted values

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-13 12:16:52 +01:00
Thomas Lamprecht
fa6e694656 inotify/interfaces: ensure cidr, address and netmask are set correctly
This should bring back compatibillity in the read site and one for
all clears that cidr is cidr, netmask is mask and address is address
(outgoing).

We're still very flexible on what can be written out.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-13 11:35:52 +01:00
Thomas Lamprecht
f110671de4 test: list ifaces: fix indentation of expected structure
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-13 11:07:17 +01:00
Thomas Lamprecht
ffe0b0e075 runtest: clone config before passing to write to avoid side effects
write changes some parts of the config, if this is a reference to the
config used for checking parsing it may lead to unexpected failures
due to those side effects..

For me it was "cidr" and "cidr6" getting deleted, and thus upcomming
tests for a compat change failing without any apparent reason.. :/

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-13 11:02:01 +01:00
Thomas Lamprecht
f6c9d9a4f3 inotify: fix compatibillity with address + netmask separate passed
fixes commit 78c6656c9aba1d57786f916717c2622a3059fb6 which dropped
writing out the netmask but missed to add compat code for the case
where the caller did not suplly a address in CIDR format already.

Check if an address ends with /\d+, if not see if a netmask is
available and add that similar how it gets handled on read.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-03-12 16:10:18 +01:00
Alexandre Derumier
36bbe29db8 INotify : fix OVSBond && OvsintPort order + tests
OVSBond was missing
OvsintPort under ethx interfaces
2020-03-07 17:48:01 +01:00
Alexandre Derumier
beedabb4ab remove extra space after address && gateway options
only 1 space like all others options

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-03-04 14:59:34 +01:00
Alexandre Derumier
378c6656c9 INotify: use cidr for address on config change
netmask/broadcast options are deprecated since buster
https://manpages.debian.org/buster/ifupdown/interfaces.5.en.html

This still read both "old address/netmask" or "address cidr" format,
but always convert it to cidr address format

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-03-04 14:59:34 +01:00
Alexandre Derumier
a70e9925ae INotify : check_bridge : fix bridge-ports with vlan tagged interface
Currently with strip vlan tag, that's wrong because
mtu && others check are done the main interface.
2020-02-07 12:56:24 +01:00
Alexandre Derumier
968c90f174 INotify: fix mtu check && add test
reverse the parent-child. (bridge-port is the parent)
2020-02-07 12:56:24 +01:00
Alexandre Derumier
f82c73738d tests: unknown interfaces order: rename vlan interfaces to unknown
vlan(X) interfaces are not unknown anymore
use generic name instead

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-01-25 16:01:34 +01:00
Thomas Lamprecht
2f98cd72a8 ProcFSTools: add kernel_version
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-23 12:15:59 +01:00
Thomas Lamprecht
510f865b5c tests: allow to make tests in parallel
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-23 12:14:19 +01:00
Alexandre Derumier
4ac94c72a2 network_interfaces: use allow-ovs for OVSBridge
new openvswitch-switch service use "ifup --allow-ovs",
and this race with "auto ..." used by networking service

bug reported here:
https://forum.proxmox.com/threads/so-is-openvswitch-bonding-just-broken-on-pve-6-whats-going-on.58020/

This is also fixing ovs with ifupdown2

Openvswitch github have a note about this:
e0dfd67b45 (diff-555e6da95251766b76e83867900bd8fe)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2019-09-20 09:06:47 +02:00
Wolfgang Bumiller
e90fc1e64b Fixup testcases for the previous commit
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-01-03 09:05:46 +01:00
Wolfgang Bumiller
f236e57602 tests: update to utc flag and add daylight savings test
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-10-31 14:56:45 +01:00
Alexandre Derumier
8f5d56bfc9 Inotify: add support for 802.1ad stacked vlans 2018-10-04 13:06:54 +02:00
Wolfgang Bumiller
8b49281929 INotify: add tests for non-defined vlan bridge ports
This tests the case covered by the previous commit

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-09-11 14:13:39 +02:00
Wolfgang Bumiller
ec0f515131 tests: test newly added interfaces individually
And add eth2/3 to /proc/net/dev, that way we don't need to
create them "virtually" (which we shouldn't, for physical
interfaces).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-07-10 12:34:10 +02:00
Alexandre Derumier
9b053d70de Inotify : add mtu option
also check if mtu value is lower than parent interface

fixme: vxlan interface should be 50bytes lower than outgoing interface
       we need to find which interface is used (unicast/multicast/frr)
2018-07-10 11:38:54 +02:00
Alexandre Derumier
c4e564708b Inotify : add check vlan
verify than parent interface exist
verify than parent interface type is eth,bond,bridge
verify than parent bridge is vlan aware if type bridge
2018-07-10 11:38:54 +02:00
Alexandre Derumier
0115696f6a Inotify : add check_bond
verify than bond slaves exist && type is eth
2018-07-10 11:38:54 +02:00
Alexandre Derumier
9a052564e1 Inotify : add bridge ports options 2018-07-10 11:38:54 +02:00
Alexandre Derumier
95aa8788b8 Inotify : add vxlan interface support 2018-07-10 11:38:54 +02:00
Wolfgang Bumiller
f6c4a56381 INotify: write network: don't duplicate bridge-vids
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-20 10:27:08 +02:00
Alexandre Derumier
1accc6da65 Inotify : write network config : use modern syntax for options
-replace options with '_'  with '-'
-use 'bond-slaves' instead 'slaves'
2018-06-20 10:11:48 +02:00