pytest-pve-cloud 3.3.0__tar.gz → 3.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {pytest_pve_cloud-3.3.0/src/pytest_pve_cloud.egg-info → pytest_pve_cloud-3.4.0}/PKG-INFO +2 -2
  2. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/requirements.txt +1 -1
  3. pytest_pve_cloud-3.4.0/src/pve_cloud_test/_version.py +1 -0
  4. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/k8s_fixtures.py +91 -0
  5. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/terraform.py +5 -18
  6. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0/src/pytest_pve_cloud.egg-info}/PKG-INFO +2 -2
  7. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pytest_pve_cloud.egg-info/requires.txt +1 -1
  8. pytest_pve_cloud-3.3.0/src/pve_cloud_test/_version.py +0 -1
  9. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/LICENSE.md +0 -0
  10. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/README.md +0 -0
  11. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/pyproject.toml +0 -0
  12. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/setup.cfg +0 -0
  13. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/cloud_fixtures.py +0 -0
  14. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/options.py +0 -0
  15. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/tdd_watchdog.py +0 -0
  16. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pve_cloud_test/test_env_schema.yaml +0 -0
  17. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pytest_pve_cloud.egg-info/SOURCES.txt +0 -0
  18. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pytest_pve_cloud.egg-info/dependency_links.txt +0 -0
  19. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pytest_pve_cloud.egg-info/entry_points.txt +0 -0
  20. {pytest_pve_cloud-3.3.0 → pytest_pve_cloud-3.4.0}/src/pytest_pve_cloud.egg-info/top_level.txt +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-pve-cloud
3
- Version: 3.3.0
3
+ Version: 3.4.0
4
4
  Author-email: Tobias Huebner <tobias.huebner@vmzberlin.com>
5
5
  License-Expression: GPL-3.0-or-later
6
6
  License-File: LICENSE.md
7
- Requires-Dist: py-pve-cloud<3.4.0,>=3.3.0
7
+ Requires-Dist: py-pve-cloud<3.5.0,>=3.4.0
8
8
  Requires-Dist: kubernetes==34.1.0
9
9
  Requires-Dist: pytest==8.4.2
10
10
  Requires-Dist: ansible-runner==2.4.2
@@ -1,4 +1,4 @@
1
- py-pve-cloud>=3.3.0,<3.4.0
1
+ py-pve-cloud>=3.4.0,<3.5.0
2
2
  kubernetes==34.1.0
3
3
  pytest==8.4.2
4
4
  ansible-runner==2.4.2
@@ -0,0 +1 @@
1
+ __version__ = "3.4.0"
@@ -1,11 +1,18 @@
1
1
  import logging
2
+ import os
2
3
  import tempfile
3
4
 
5
+ import dns.query
6
+ import dns.rcode
7
+ import dns.resolver
8
+ import dns.tsigkeyring
9
+ import dns.update
4
10
  import paramiko
5
11
  import pytest
6
12
  import yaml
7
13
  from kubernetes import client, config
8
14
  from proxmoxer import ProxmoxAPI
15
+ from pve_cloud.lib.ssh import connect_host
9
16
 
10
17
  from pve_cloud_test.cloud_fixtures import get_test_env
11
18
 
@@ -419,3 +426,87 @@ def get_k8s_secondary_api_v1(get_secondary_kubeconfig):
419
426
  v1 = client.CoreV1Api()
420
427
 
421
428
  return v1
429
+
430
+
431
+ def construct_k0s_ext_hosts_inv(get_test_env):
432
+ resolver = dns.resolver.Resolver()
433
+ resolver.nameservers = [get_test_env["cloud_inventory"]["bind_master_ip"]]
434
+
435
+ ddns_answer = resolver.resolve(
436
+ f"single-pytest-k0s-edge.{get_test_env['cloud_inventory']['pve_cloud_domain']}"
437
+ )
438
+ ddns_ips = [rdata.to_text() for rdata in ddns_answer]
439
+ logger.info(ddns_ips)
440
+ assert ddns_ips # assert ddns response
441
+
442
+ with tempfile.NamedTemporaryFile("w", suffix=".yaml", delete=False) as temp_k0s_inv:
443
+ yaml.dump(
444
+ {
445
+ "plugin": "pxc.cloud.ext_hosts_inv",
446
+ "pve_cloud_domain": get_test_env["cloud_inventory"]["pve_cloud_domain"],
447
+ "target_cluster": get_test_env["pve_test_cluster_name"],
448
+ "external_stack_name": "pytest-k0s",
449
+ "typed_host_groups": {
450
+ "k0s_edge": {
451
+ "k0s_single": {
452
+ "ansible_user": "admin",
453
+ "ansible_host": ddns_ips[0],
454
+ "k0s_conf_local_path": f"{os.getenv('ANSIBLE_COLLECTIONS_PATH')}/ansible_collections/pxc/cloud/tests/files/k0s.yaml",
455
+ "zfs_containerd_dataset": True,
456
+ "zpool_csi_parameters": {
457
+ "pool_properties": {"ashift": "12"},
458
+ "vdevs": [
459
+ {
460
+ "disks": [
461
+ "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1"
462
+ ]
463
+ },
464
+ ],
465
+ },
466
+ "e2e_limit_containerd_downloads": get_e2e_limit_feature(
467
+ get_test_env, "limit_containerd_downloads"
468
+ ),
469
+ }
470
+ }
471
+ },
472
+ },
473
+ temp_k0s_inv,
474
+ )
475
+ temp_k0s_inv.flush()
476
+ logger.info(f"ext hosts inv {temp_k0s_inv.name}")
477
+
478
+ return temp_k0s_inv.name, ddns_ips[0]
479
+
480
+
481
+ @pytest.fixture(scope="session")
482
+ def get_k0s_api_v1(get_test_env):
483
+ _, k0s_host = construct_k0s_ext_hosts_inv(get_test_env)
484
+
485
+ with connect_host(k0s_host, user="admin") as ssh:
486
+ _, stdout, _ = ssh.exec_command("sudo k0s kubeconfig admin")
487
+
488
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_file:
489
+ temp_file.write(stdout.read().decode("utf-8"))
490
+ temp_file.flush()
491
+ config.load_kube_config(config_file=temp_file.name)
492
+
493
+ v1 = client.CoreV1Api()
494
+
495
+ return v1
496
+
497
+
498
+ @pytest.fixture(scope="session")
499
+ def get_k0s_api_v1_batch(get_test_env):
500
+ _, k0s_host = construct_k0s_ext_hosts_inv(get_test_env)
501
+
502
+ with connect_host(k0s_host, user="admin") as ssh:
503
+ _, stdout, _ = ssh.exec_command("sudo k0s kubeconfig admin")
504
+
505
+ with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_file:
506
+ temp_file.write(stdout.read().decode("utf-8"))
507
+ temp_file.flush()
508
+ config.load_kube_config(config_file=temp_file.name)
509
+
510
+ v1 = client.BatchV1Api()
511
+
512
+ return v1
@@ -30,9 +30,7 @@ def get_ipv4(iface):
30
30
  return None
31
31
 
32
32
 
33
- def get_tf_env_vars(
34
- module_name, scenario_name, kube_v1, get_test_env, get_kubespray_inv
35
- ):
33
+ def get_tf_env_vars(module_name, scenario_name, get_test_env):
36
34
  # set env vars for terraform backend / variables passed via env
37
35
  tf_env_vars = {}
38
36
  tf_env_vars["PG_SCHEMA_NAME"] = f"pytest-{module_name}-{scenario_name}"
@@ -81,9 +79,6 @@ def get_tf_env_vars(
81
79
 
82
80
  tf_env_vars["TF_CLI_CONFIG_FILE"] = f"{os.getcwd()}/tests/.terraformrc-e2e"
83
81
 
84
- # write testing kubespray inv and set the path (for provider init)
85
- tf_env_vars["TF_VAR_e2e_kubespray_inv"] = get_kubespray_inv
86
-
87
82
  # if the harbor_copy_mirror_host is defined in the kubernetes section, we set is as an env variable
88
83
  # to use in the pxc_helm_mirror terraform resource
89
84
  if "harbor_copy_mirror_host" in get_test_env["kubernetes"]:
@@ -140,14 +135,10 @@ def get_tf_env_vars(
140
135
  return tf_env_vars
141
136
 
142
137
 
143
- def apply(
144
- module_name, scenario_name, kube_v1, get_test_env, get_kubespray_inv, extra_env={}
145
- ):
138
+ def apply(module_name, scenario_name, kube_v1, get_test_env, extra_env={}):
146
139
  logger.info(f"applying terraform {scenario_name}")
147
140
 
148
- tf_env_vars = get_tf_env_vars(
149
- module_name, scenario_name, kube_v1, get_test_env, get_kubespray_inv
150
- )
141
+ tf_env_vars = get_tf_env_vars(module_name, scenario_name, get_test_env)
151
142
 
152
143
  # create env to pass to tf procs + write sourcable debug.env file
153
144
  terraform_env = os.environ.copy()
@@ -204,14 +195,10 @@ def apply(
204
195
  logger.info("pods still initializing")
205
196
 
206
197
 
207
- def destroy(
208
- module_name, scenario_name, kube_v1, get_test_env, get_kubespray_inv, extra_env={}
209
- ):
198
+ def destroy(module_name, scenario_name, get_test_env, extra_env={}):
210
199
  logger.info(f"destroying terraform {scenario_name}")
211
200
 
212
- tf_env_vars = get_tf_env_vars(
213
- module_name, scenario_name, kube_v1, get_test_env, get_kubespray_inv
214
- )
201
+ tf_env_vars = get_tf_env_vars(module_name, scenario_name, get_test_env)
215
202
 
216
203
  # create env to pass to tf procs + write sourcable debug.env file
217
204
  terraform_env = os.environ.copy()
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-pve-cloud
3
- Version: 3.3.0
3
+ Version: 3.4.0
4
4
  Author-email: Tobias Huebner <tobias.huebner@vmzberlin.com>
5
5
  License-Expression: GPL-3.0-or-later
6
6
  License-File: LICENSE.md
7
- Requires-Dist: py-pve-cloud<3.4.0,>=3.3.0
7
+ Requires-Dist: py-pve-cloud<3.5.0,>=3.4.0
8
8
  Requires-Dist: kubernetes==34.1.0
9
9
  Requires-Dist: pytest==8.4.2
10
10
  Requires-Dist: ansible-runner==2.4.2
@@ -1,4 +1,4 @@
1
- py-pve-cloud<3.4.0,>=3.3.0
1
+ py-pve-cloud<3.5.0,>=3.4.0
2
2
  kubernetes==34.1.0
3
3
  pytest==8.4.2
4
4
  ansible-runner==2.4.2
@@ -1 +0,0 @@
1
- __version__ = "3.3.0"