Addressed comments in PR.
[osm/N2VC.git] / examples / config.py
index 616c780..eda9891 100644 (file)
@@ -11,6 +11,9 @@ import logging
 
 from juju.model import Model
 
+log = logging.getLogger(__name__)
+
+MB = 1024 * 1024
 
 async def run():
     model = Model()
@@ -22,12 +25,23 @@ async def run():
         service_name='mysql',
         series='trusty',
         channel='stable',
+        config={
+            'tuning-level': 'safest',
+        },
         constraints={
-            'mem': 512 * 1024 * 1024
+            'mem': 256 * MB,
         },
     )
-    print(await ubuntu_app.get_config())
-    print(await ubuntu_app.get_constraints())
+
+    # update and check app config
+    await ubuntu_app.set_config({'tuning-level': 'fast'})
+    config = await ubuntu_app.get_config()
+    assert(config['tuning-level']['value'] == 'fast')
+
+    # update and check app constraints
+    await ubuntu_app.set_constraints({'mem': 512 * MB})
+    constraints = await ubuntu_app.get_constraints()
+    assert(constraints['mem'] == 512 * MB)
 
     await model.disconnect()
     model.loop.stop()