]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: move test_valid_snmp_gateway_spec from mgr/cephadm 44529/head
authorSebastian Wagner <sewagner@redhat.com>
Mon, 20 Dec 2021 10:48:43 +0000 (11:48 +0100)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 18 Jan 2022 10:45:24 +0000 (11:45 +0100)
We have to validate to_json() now as well, as we have spcial enums.
Otherwiese we might end up with !!python... representations.

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit 303843b476b442d0d398680b23aa244633768f29)

src/pybind/mgr/cephadm/tests/test_spec.py
src/python-common/ceph/tests/test_service_spec.py

index 23f06e668e760fae4199a024ad04046123120cf0..54aa0a7ab75eb31ae1d0cae90fd06b81b26ab07f 100644 (file)
@@ -3,7 +3,6 @@
 # fmt: off
 
 import json
-import yaml
 
 import pytest
 
@@ -599,62 +598,3 @@ def test_daemon_description_service_name(spec: ServiceSpec,
     else:
         with pytest.raises(OrchestratorError):
             dd.service_name()
-
-
-class YAMLdoc:
-    def __init__(self, text):
-        self.content = yaml.safe_load(text)
-
-
-@pytest.mark.parametrize(
-    "yaml_doc,snmp_type", [
-        (YAMLdoc("""
----
-service_type: snmp-gateway
-service_name: snmp-gateway
-placement:
-  count: 1
-spec:
-  credentials:
-    snmp_community: public
-port: 9464
-snmp_destination: 192.168.1.42:162
-snmp_version: V2c
-"""), 'snmp V2c'),
-        (YAMLdoc("""
----
-service_type: snmp-gateway
-service_name: snmp-gateway
-placement:
-  count: 1
-spec:
-  credentials:
-    snmp_v3_auth_username: myuser
-    snmp_v3_auth_password: mypassword
-port: 9464
-engine_id: 8000C53F00000000
-auth_protocol: MD5
-snmp_destination: 192.168.1.42:162
-snmp_version: V3
-"""), 'SNMP V3 authNoPriv'),
-        (YAMLdoc("""
----
-service_type: snmp-gateway
-service_name: snmp-gateway
-placement:
-  count: 1
-spec:
-  credentials:
-    snmp_v3_auth_username: myuser
-    snmp_v3_auth_password: mypassword
-    snmp_v3_priv_password: mysecret
-port: 9464
-engine_id: 8000C53F00000000
-privacy_protocol: AES
-snmp_destination: 192.168.1.42:162
-snmp_version: V3
-"""), 'SNMP V3 authPriv'),
-    ])
-def test_valid_snmp_gateway_spec(yaml_doc: YAMLdoc, snmp_type: str):
-    spec = ServiceSpec.from_json(yaml_doc.content)
-    spec.validate()
index eb01bd4f5a11bfdd92fa739c202d39499f0565ec..d63705324068f06172a680fa88e4e2c930eecc0c 100644 (file)
@@ -321,6 +321,44 @@ spec:
   uid: 1000
   volume_mounts:
     foo: /foo
+---
+service_type: snmp-gateway
+service_name: snmp-gateway
+placement:
+  count: 1
+spec:
+  credentials:
+    snmp_community: public
+  snmp_destination: 192.168.1.42:162
+  snmp_version: V2c
+---
+service_type: snmp-gateway
+service_name: snmp-gateway
+placement:
+  count: 1
+spec:
+  auth_protocol: MD5
+  credentials:
+    snmp_v3_auth_password: mypassword
+    snmp_v3_auth_username: myuser
+  engine_id: 8000C53F00000000
+  port: 9464
+  snmp_destination: 192.168.1.42:162
+  snmp_version: V3
+---
+service_type: snmp-gateway
+service_name: snmp-gateway
+placement:
+  count: 1
+spec:
+  credentials:
+    snmp_v3_auth_password: mypassword
+    snmp_v3_auth_username: myuser
+    snmp_v3_priv_password: mysecret
+  engine_id: 8000C53F00000000
+  privacy_protocol: AES
+  snmp_destination: 192.168.1.42:162
+  snmp_version: V3
 """.split('---\n'))
 def test_yaml(y):
     data = yaml.safe_load(y)