]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: move test_valid_snmp_gateway_spec from mgr/cephadm 44341/head
authorSebastian Wagner <sewagner@redhat.com>
Mon, 20 Dec 2021 10:48:43 +0000 (11:48 +0100)
committerSebastian Wagner <sewagner@redhat.com>
Wed, 5 Jan 2022 09:24:42 +0000 (10:24 +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>
src/pybind/mgr/cephadm/tests/test_spec.py
src/python-common/ceph/tests/test_service_spec.py

index 436aae5d6f2eeb34c82cbeb9d328889468f6fa00..c89d3b6c1ca6443f60737a26ecaae8e53e1293b9 100644 (file)
@@ -3,7 +3,6 @@
 # fmt: off
 
 import json
-import yaml
 
 import pytest
 
@@ -587,62 +586,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 fd284f481338ccb3aa96cfa59210c663dd998cf4..080e57732170231ae0d516992b7522096227edab 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)