Re: [libvirt] [dbus PATCH] Add detail argument to DomainEvent signal

2018-05-04 Thread Pavel Hrdina
On Fri, May 04, 2018 at 11:45:59AM +0200, Katerina Koukiou wrote:
> Adjust all DomainEvent tests to do detail type checking.
> 
> Signed-off-by: Katerina Koukiou 
> ---
> This commit is rebased on top of unmerged patches for removing enum<->string
> translation.
> 
>  data/org.libvirt.Connect.xml |  1 +
>  src/events.c |  4 ++--
>  tests/libvirttest.py | 55 
> 
>  tests/test_connect.py|  6 +++--
>  tests/test_domain.py | 15 
>  5 files changed, 72 insertions(+), 9 deletions(-)

Reviewed-by: Pavel Hrdina 

Similar thing should be done for Domain.State property.


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [dbus PATCH] Add detail argument to DomainEvent signal

2018-05-04 Thread Katerina Koukiou
Adjust all DomainEvent tests to do detail type checking.

Signed-off-by: Katerina Koukiou 
---
This commit is rebased on top of unmerged patches for removing enum<->string
translation.

 data/org.libvirt.Connect.xml |  1 +
 src/events.c |  4 ++--
 tests/libvirttest.py | 55 
 tests/test_connect.py|  6 +++--
 tests/test_domain.py | 15 
 5 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 8272da6..0f1456f 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -171,6 +171,7 @@
 value="See 
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
   
   
+  
 
 
   connectPath,
   VIRT_DBUS_CONNECT_INTERFACE,
   "DomainEvent",
-  g_variant_new("(ou)", path, event),
+  g_variant_new("(ouu)", path, event, detail),
   NULL);
 
 return 0;
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index 06ac0e4..eee67a0 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -100,6 +100,61 @@ class DomainEvent(IntEnum):
 CRASHED = 8
 
 
+class DomainEventDefinedDetailType(IntEnum):
+ADDED = 0
+UPDATED = 1
+RENAMED = 2
+FROM_SNAPSHOT = 3
+LAST = 4
+
+
+class DomainEventResumedDetailType(IntEnum):
+UNPAUSED = 0
+MIGRATED = 1
+FROM_SNAPSHOT = 2
+POSTCOPY = 3
+LAST = 4
+
+
+class DomainEventStartedDetailType(IntEnum):
+BOOTED = 0
+MIGRATED = 1
+RESTORED = 2
+FROM_SNAPSHOT = 3
+WAKEUP = 4
+LAST = 5
+
+
+class DomainEventStoppedDetailType(IntEnum):
+SHUTDOWN = 0
+DESTROYED = 1
+CRASHED = 2
+MIGRATED = 3
+SAVED = 4
+FAILED = 5
+FROM_SNAPSHOT = 6
+LAST = 7
+
+
+class DomainEventSuspendedDetailType(IntEnum):
+PAUSED = 0
+MIGRATED   = 1
+IOERROR = 2
+WATCHDOG   = 3
+RESTORED = 4
+FROM_SNAPSHOT = 5
+API_ERROR = 6
+POSTCOPY = 7
+POSTCOPY_FAILED = 8
+LAST = 9
+
+
+class DomainEventUndefinedDetailType(IntEnum):
+REMOVED = 0
+RENAMED = 1
+LAST = 2
+
+
 class DomainState(IntEnum):
 NOSTATE = 0
 RUNNING = 1
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 7748822..a2bd17f 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -31,9 +31,10 @@ class TestConnect(libvirttest.BaseTestClass):
 '''
 
 def test_connect_domain_create_xml(self):
-def domain_started(path, event):
+def domain_started(path, event, detail):
 if event != libvirttest.DomainEvent.STARTED:
 return
+assert detail == libvirttest.DomainEventStartedDetailType.BOOTED
 assert isinstance(path, dbus.ObjectPath)
 self.loop.quit()
 
@@ -45,9 +46,10 @@ class TestConnect(libvirttest.BaseTestClass):
 self.main_loop()
 
 def test_comnect_domain_define_xml(self):
-def domain_defined(path, event):
+def domain_defined(path, event, detail):
 if event != libvirttest.DomainEvent.DEFINED:
 return
+assert detail == libvirttest.DomainEventDefinedDetailType.ADDED
 assert isinstance(path, dbus.ObjectPath)
 self.loop.quit()
 
diff --git a/tests/test_domain.py b/tests/test_domain.py
index c7e09cd..dfa19ed 100755
--- a/tests/test_domain.py
+++ b/tests/test_domain.py
@@ -47,9 +47,10 @@ class TestDomain(libvirttest.BaseTestClass):
 assert autostart_current == dbus.Boolean(autostart_expected)
 
 def test_domain_managed_save(self):
-def domain_stopped(path, event):
+def domain_stopped(path, event, detail):
 if event != libvirttest.DomainEvent.STOPPED:
 return
+assert detail == libvirttest.DomainEventStoppedDetailType.SAVED
 assert isinstance(path, dbus.ObjectPath)
 self.loop.quit()
 
@@ -74,9 +75,10 @@ class TestDomain(libvirttest.BaseTestClass):
 assert description_expected == 
domain.GetMetadata(metadata_description, "", 0)
 
 def test_resume(self):
-def domain_resumed(path, event):
+def domain_resumed(path, event, detail):
 if event != libvirttest.DomainEvent.RESUMED:
 return
+assert detail == libvirttest.DomainEventResumedDetailType.UNPAUSED
 assert isinstance(path, dbus.ObjectPath)
 self.loop.quit()
 
@@ -92,9 +94,10 @@ class TestDomain(libvirttest.BaseTestClass):
 self.main_loop()
 
 def test_shutdown(self):
-def domain_stopped(path, event):
+def domain_stopped(path, event, detail):
 if event != libvirttest.DomainEvent.STOPPED:
 return
+