CORD-1393: Allow accessor.kind config variable to turn off modelaccessor for faster unit tests
Change-Id: Ida5260afc2bb35fba56e946f3a55d3ba22adf2af
diff --git a/lib/xos-config/xosconfig/default.py b/lib/xos-config/xosconfig/default.py
index f5cd761..2068c13 100644
--- a/lib/xos-config/xosconfig/default.py
+++ b/lib/xos-config/xosconfig/default.py
@@ -8,6 +8,7 @@
},
'accessor': {
'endpoint': 'xos-core.cord.lab:50051',
+ 'kind': 'grpcapi',
},
'keep_temp_files': False,
'enable_watchers': False,
@@ -24,4 +25,4 @@
'node_key': '/opt/cord_profile/node_key',
'config_dir': '/etc/xos/sync',
'backoff_disabled': True
-}
\ No newline at end of file
+}
diff --git a/lib/xos-config/xosconfig/synchronizer-config-schema.yaml b/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
index 640d61c..f41c7b2 100644
--- a/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
+++ b/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
@@ -32,6 +32,9 @@
password:
type: str
required: True
+ kind:
+ type: str
+ required: False
required_models:
type: seq
sequence:
diff --git a/xos/synchronizers/new_base/model_policies/test_config.yaml b/xos/synchronizers/new_base/model_policies/test_config.yaml
index c05965e..c8e1b4b 100644
--- a/xos/synchronizers/new_base/model_policies/test_config.yaml
+++ b/xos/synchronizers/new_base/model_policies/test_config.yaml
@@ -2,3 +2,4 @@
accessor:
username: xosadmin@opencord.org
password: "sample"
+ kind: testframework
\ No newline at end of file
diff --git a/xos/synchronizers/new_base/modelaccessor.py b/xos/synchronizers/new_base/modelaccessor.py
index 8c6fbe7..89ee257 100644
--- a/xos/synchronizers/new_base/modelaccessor.py
+++ b/xos/synchronizers/new_base/modelaccessor.py
@@ -19,6 +19,7 @@
logger = Logger(level=logging.INFO)
orig_sigint = None
+model_accessor = None
class ModelAccessor(object):
@@ -178,8 +179,7 @@
signal.signal(signal.SIGINT, orig_sigint)
-def config_accessor():
- global model_accessor
+def config_accessor_grpcapi():
global orig_sigint
grpcapi_endpoint = Config.get("accessor.endpoint")
@@ -212,5 +212,14 @@
reactor.run()
+def config_accessor():
+ accessor_kind = Config.get("accessor.kind")
+
+ if accessor_kind == "testframework":
+ pass
+ elif accessor_kind == "grpcapi":
+ config_accessor_grpcapi()
+ else:
+ raise Exception("Unknown accessor kind %s" % accessor_kind)
config_accessor()