public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container 0/2] add test for LXC_NAME hosts entry and fix a minor glitch
@ 2023-06-14 10:43 Stoiko Ivanov
  2023-06-14 10:43 ` [pve-devel] [PATCH container 1/2] tests: fix small syntax glitch Stoiko Ivanov
  2023-06-14 10:43 ` [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry Stoiko Ivanov
  0 siblings, 2 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2023-06-14 10:43 UTC (permalink / raw)
  To: pve-devel

the patch from:
https://lists.proxmox.com/pipermail/pve-devel/2023-June/057420.html
broke the setup for templates which don't contain /etc/hosts.
This was fixed in a follow-up by Thomas.
Sorry for not noticing the broken tests (they are currently skipped if
building with sbuild, which I used)!

patch 2 adds an explicit test for the functionality in the patch

While checking the output I noticed a small glitch with Test::MockModule
in the snapshot-test.pm - which should be addressed with patch 1 of this
series.

Stoiko Ivanov (2):
  tests: fix small syntax glitch
  tests: add minimal test for LXC_NAME hosts entry

 src/test/snapshot-test.pm                     | 12 +++++------
 src/test/test-alpine-003/config               |  2 ++
 src/test/test-alpine-003/etc/alpine-release   |  1 +
 src/test/test-alpine-003/etc/hostname.exp     |  1 +
 src/test/test-alpine-003/etc/hosts            |  5 +++++
 src/test/test-alpine-003/etc/hosts.exp        |  5 +++++
 .../test-alpine-003/etc/network/interfaces    |  0
 src/test/test-alpine-003/etc/passwd           | 21 +++++++++++++++++++
 .../roothome/.ssh/authorized_keys.exp         |  3 +++
 9 files changed, 44 insertions(+), 6 deletions(-)
 create mode 100644 src/test/test-alpine-003/config
 create mode 100644 src/test/test-alpine-003/etc/alpine-release
 create mode 100644 src/test/test-alpine-003/etc/hostname.exp
 create mode 100644 src/test/test-alpine-003/etc/hosts
 create mode 100644 src/test/test-alpine-003/etc/hosts.exp
 create mode 100644 src/test/test-alpine-003/etc/network/interfaces
 create mode 100644 src/test/test-alpine-003/etc/passwd
 create mode 100644 src/test/test-alpine-003/roothome/.ssh/authorized_keys.exp

-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH container 1/2] tests: fix small syntax glitch
  2023-06-14 10:43 [pve-devel] [PATCH container 0/2] add test for LXC_NAME hosts entry and fix a minor glitch Stoiko Ivanov
@ 2023-06-14 10:43 ` Stoiko Ivanov
  2023-06-14 10:43 ` [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry Stoiko Ivanov
  1 sibling, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2023-06-14 10:43 UTC (permalink / raw)
  To: pve-devel

adaptation to adhere to perlcritics recommendation led to the snapshot
tests to not work anymore:
```
Undefined subroutine &Test::MockModule called at snapshot-test.pm line 300.
```

With this the snapshot tests still run and perlcritic seems happy

Fixes: f505de300431134b202ad5a88f55721cb95e6fe4
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/test/snapshot-test.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/test/snapshot-test.pm b/src/test/snapshot-test.pm
index 8e6e9c2..f9b1616 100644
--- a/src/test/snapshot-test.pm
+++ b/src/test/snapshot-test.pm
@@ -297,21 +297,21 @@ PVE::Tools::run_command("cp -a snapshot-input snapshot-working");
 
 printf("\n");
 printf("Setting up Mocking for PVE::LXC and PVE::LXC::Config\n");
-my $lxc_module = Test::MockModule('PVE::LXC')->new();
+my $lxc_module = Test::MockModule->new('PVE::LXC');
 $lxc_module->mock('sync_container_namespace', sub { return; });
 $lxc_module->mock('check_running', \&mocked_check_running);
 $lxc_module->mock('vm_stop', \&mocked_vm_stop);
 $lxc_module->mock('freeze', \&mocked_freeze);
 $lxc_module->mock('thaw', \&mocked_freeze); # re-use, as for now we don't care
 
-my $lxc_config_module = Test::MockModule('PVE::LXC::Config')->new();
+my $lxc_config_module = Test::MockModule->new('PVE::LXC::Config');
 $lxc_config_module->mock('config_file_lock', sub { return "snapshot-working/pve-test.lock"; });
 $lxc_config_module->mock('cfs_config_path', \&mocked_cfs_config_path);
 $lxc_config_module->mock('load_config', \&mocked_load_config);
 $lxc_config_module->mock('write_config', \&mocked_write_config);
 $lxc_config_module->mock('has_feature', \&mocked_has_feature);
 
-my $pve_cluster_module = Test::MockModule('PVE::Cluster')->new();
+my $pve_cluster_module = Test::MockModule->new('PVE::Cluster');
 sub mocked_get_config {
     my ($path) = @_;
     return PVE::Tools::file_get_contents("snapshot-working/$path");
@@ -319,7 +319,7 @@ sub mocked_get_config {
 $pve_cluster_module->mock('get_config', \&mocked_get_config);
 
 # ignore existing replication config
-my $repl_config_module = Test::MockModule('PVE::ReplicationConfig')->new();
+my $repl_config_module = Test::MockModule->new('PVE::ReplicationConfig');
 $repl_config_module->mock('check_for_existing_jobs' => sub { return undef });
 
 $running = 1;
@@ -399,7 +399,7 @@ $vol_snapshot_rollback_possible->{"local:snapshotable-disk-4"} = 1;
 
 printf("\n");
 printf("Setting up Mocking for PVE::Storage\n");
-my $storage_module = Test::MockModule('PVE::Storage')->new();
+my $storage_module = Test::MockModule->new('PVE::Storage');
 $storage_module->mock('activate_storage', \&mocked_activate_storage);
 $storage_module->mock('config', sub { return undef; });
 $storage_module->mock('volume_snapshot', \&mocked_volume_snapshot);
@@ -411,7 +411,7 @@ printf("\tconfig(), volume_snapshot(), volume_snapshot_delete(), volume_snapshot
 
 printf("\n");
 printf("Setting up Mocking for PVE::Tools\n");
-my $tools_module = Test::MockModule('PVE::Tools')->new();
+my $tools_module = Test::MockModule->new('PVE::Tools');
 $tools_module->mock('run_command' => \&mocked_run_command);
 printf("\trun_command() mocked\n");
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry
  2023-06-14 10:43 [pve-devel] [PATCH container 0/2] add test for LXC_NAME hosts entry and fix a minor glitch Stoiko Ivanov
  2023-06-14 10:43 ` [pve-devel] [PATCH container 1/2] tests: fix small syntax glitch Stoiko Ivanov
@ 2023-06-14 10:43 ` Stoiko Ivanov
  2023-06-14 11:32   ` Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Stoiko Ivanov @ 2023-06-14 10:43 UTC (permalink / raw)
  To: pve-devel

based on test-alpine-002

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/test/test-alpine-003/config               |  2 ++
 src/test/test-alpine-003/etc/alpine-release   |  1 +
 src/test/test-alpine-003/etc/hostname.exp     |  1 +
 src/test/test-alpine-003/etc/hosts            |  5 +++++
 src/test/test-alpine-003/etc/hosts.exp        |  5 +++++
 .../test-alpine-003/etc/network/interfaces    |  0
 src/test/test-alpine-003/etc/passwd           | 21 +++++++++++++++++++
 .../roothome/.ssh/authorized_keys.exp         |  3 +++
 8 files changed, 38 insertions(+)
 create mode 100644 src/test/test-alpine-003/config
 create mode 100644 src/test/test-alpine-003/etc/alpine-release
 create mode 100644 src/test/test-alpine-003/etc/hostname.exp
 create mode 100644 src/test/test-alpine-003/etc/hosts
 create mode 100644 src/test/test-alpine-003/etc/hosts.exp
 create mode 100644 src/test/test-alpine-003/etc/network/interfaces
 create mode 100644 src/test/test-alpine-003/etc/passwd
 create mode 100644 src/test/test-alpine-003/roothome/.ssh/authorized_keys.exp

diff --git a/src/test/test-alpine-003/config b/src/test/test-alpine-003/config
new file mode 100644
index 0000000..9e8a6b7
--- /dev/null
+++ b/src/test/test-alpine-003/config
@@ -0,0 +1,2 @@
+hostname: test3
+net0: name=eth0,hwaddr=12:22:33:44:55:66,bridge=vmbr0,ip=10.0.0.100/32,gw=11.0.0.1
diff --git a/src/test/test-alpine-003/etc/alpine-release b/src/test/test-alpine-003/etc/alpine-release
new file mode 100644
index 0000000..c10780c
--- /dev/null
+++ b/src/test/test-alpine-003/etc/alpine-release
@@ -0,0 +1 @@
+3.13.1
diff --git a/src/test/test-alpine-003/etc/hostname.exp b/src/test/test-alpine-003/etc/hostname.exp
new file mode 100644
index 0000000..df6b0d2
--- /dev/null
+++ b/src/test/test-alpine-003/etc/hostname.exp
@@ -0,0 +1 @@
+test3
diff --git a/src/test/test-alpine-003/etc/hosts b/src/test/test-alpine-003/etc/hosts
new file mode 100644
index 0000000..22ec15f
--- /dev/null
+++ b/src/test/test-alpine-003/etc/hosts
@@ -0,0 +1,5 @@
+127.0.0.1	localhost localhost.localdomain
+::1		localhost localhost.localdomain
+# --- BEGIN PVE ---
+127.0.1.1 test3.proxmox.com test3
+# --- END PVE ---
diff --git a/src/test/test-alpine-003/etc/hosts.exp b/src/test/test-alpine-003/etc/hosts.exp
new file mode 100644
index 0000000..1d122ce
--- /dev/null
+++ b/src/test/test-alpine-003/etc/hosts.exp
@@ -0,0 +1,5 @@
+127.0.0.1	localhost localhost.localdomain
+::1		localhost localhost.localdomain
+# --- BEGIN PVE ---
+10.0.0.100 test3.proxmox.com test3
+# --- END PVE ---
diff --git a/src/test/test-alpine-003/etc/network/interfaces b/src/test/test-alpine-003/etc/network/interfaces
new file mode 100644
index 0000000..e69de29
diff --git a/src/test/test-alpine-003/etc/passwd b/src/test/test-alpine-003/etc/passwd
new file mode 100644
index 0000000..9fc110f
--- /dev/null
+++ b/src/test/test-alpine-003/etc/passwd
@@ -0,0 +1,21 @@
+root:x:0:0:root:/roothome:/bin/bash
+daemon:x:1:1:daemon:/usr/sbin:/bin/sh
+bin:x:2:2:bin:/bin:/bin/sh
+sys:x:3:3:sys:/dev:/bin/sh
+sync:x:4:65534:sync:/bin:/bin/sync
+games:x:5:60:games:/usr/games:/bin/sh
+man:x:6:12:man:/var/cache/man:/bin/sh
+lp:x:7:7:lp:/var/spool/lpd:/bin/sh
+mail:x:8:8:mail:/var/mail:/bin/sh
+news:x:9:9:news:/var/spool/news:/bin/sh
+uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
+proxy:x:13:13:proxy:/bin:/bin/sh
+www-data:x:33:33:www-data:/var/www:/bin/sh
+backup:x:34:34:backup:/var/backups:/bin/sh
+list:x:38:38:Mailing List Manager:/var/list:/bin/sh
+irc:x:39:39:ircd:/var/run/ircd:/bin/sh
+gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
+nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+libuuid:x:100:101::/var/lib/libuuid:/bin/sh
+postfix:x:101:104::/var/spool/postfix:/bin/false
+sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
diff --git a/src/test/test-alpine-003/roothome/.ssh/authorized_keys.exp b/src/test/test-alpine-003/roothome/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-alpine-003/roothome/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC@DEF
+# --- END PVE ---
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry
  2023-06-14 10:43 ` [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry Stoiko Ivanov
@ 2023-06-14 11:32   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2023-06-14 11:32 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stoiko Ivanov

Am 14/06/2023 um 12:43 schrieb Stoiko Ivanov:
> +++ b/src/test/test-alpine-003/etc/hosts
> @@ -0,0 +1,5 @@
> +127.0.0.1	localhost localhost.localdomain
> +::1		localhost localhost.localdomain


Misses the "LXC_NAME" line we want to test that it gets removed?

> +# --- BEGIN PVE ---
> +127.0.1.1 test3.proxmox.com test3
> +# --- END PVE ---
> diff --git a/src/test/test-alpine-003/etc/hosts.exp b/src/test/test-alpine-003/etc/hosts.exp
> new file mode 100644
> index 0000000..1d122ce
> --- /dev/null
> +++ b/src/test/test-alpine-003/etc/hosts.exp
> @@ -0,0 +1,5 @@
> +127.0.0.1	localhost localhost.localdomain
> +::1		localhost localhost.localdomain
> +# --- BEGIN PVE ---
> +10.0.0.100 test3.proxmox.com test3
> +# --- END PVE ---
i.e. hosts.exp is identical with hosts?




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-14 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 10:43 [pve-devel] [PATCH container 0/2] add test for LXC_NAME hosts entry and fix a minor glitch Stoiko Ivanov
2023-06-14 10:43 ` [pve-devel] [PATCH container 1/2] tests: fix small syntax glitch Stoiko Ivanov
2023-06-14 10:43 ` [pve-devel] [PATCH container 2/2] tests: add minimal test for LXC_NAME hosts entry Stoiko Ivanov
2023-06-14 11:32   ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal