def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch
         and deletedEpoch
     """
     subnet = Subnet()
     subnet.set_id('subnet-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.subnet_save(self.admin_context, subnet)
     epoch_after = utils.get_current_epoch_ms()
     subnet_queried = healthnmon_db_api. \
         subnet_get_by_ids(self.admin_context, [subnet.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, subnet_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     subnet_modified = subnet_queried
     test_utils.unset_timestamp_fields(subnet_modified)
     subnet_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.subnet_save(self.admin_context, subnet_modified)
     epoch_after = utils.get_current_epoch_ms()
     subnet_queried = healthnmon_db_api.subnet_get_by_ids(
         self.admin_context, [subnet.get_id()])[0]
     self.assert_(subnet_modified.get_createEpoch() ==
                  subnet_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, subnet_queried.get_lastModifiedEpoch()))
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     vol = StorageVolume()
     vol.set_id('vol-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vol_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     vol_modified = vol_queried
     test_utils.unset_timestamp_fields(vol_modified)
     vol_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol_modified)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(
         vol_modified.get_createEpoch() == vol_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vol_queried.get_lastModifiedEpoch()))
예제 #3
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     portGrp = PortGroup()
     portGrp.set_id('portGrp-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.port_group_save(get_admin_context(), portGrp)
     epoch_after = utils.get_current_epoch_ms()
     portGrp_queried = api.port_group_get_by_ids(
         get_admin_context(), [portGrp.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, portGrp_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     portGrp_modified = portGrp_queried
     test_utils.unset_timestamp_fields(portGrp_modified)
     portGrp_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     api.port_group_save(get_admin_context(), portGrp_modified)
     epoch_after = utils.get_current_epoch_ms()
     portGrp_queried = api.port_group_get_by_ids(
         get_admin_context(), [portGrp.get_id()])[0]
     self.assert_(portGrp_modified.get_createEpoch(
     ) == portGrp_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before,
         epoch_after,
         portGrp_queried.get_lastModifiedEpoch()))
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     vol = StorageVolume()
     vol.set_id('vol-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         vol_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     vol_modified = vol_queried
     test_utils.unset_timestamp_fields(vol_modified)
     vol_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol_modified)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(
         vol_modified.get_createEpoch() == vol_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vol_queried.get_lastModifiedEpoch()))
예제 #5
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch
         and deletedEpoch
     """
     subnet = Subnet()
     subnet.set_id('subnet-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.subnet_save(self.admin_context, subnet)
     epoch_after = utils.get_current_epoch_ms()
     subnet_queried = healthnmon_db_api. \
         subnet_get_by_ids(self.admin_context, [subnet.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, subnet_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     subnet_modified = subnet_queried
     test_utils.unset_timestamp_fields(subnet_modified)
     subnet_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.subnet_save(self.admin_context, subnet_modified)
     epoch_after = utils.get_current_epoch_ms()
     subnet_queried = healthnmon_db_api.subnet_get_by_ids(
         self.admin_context, [subnet.get_id()])[0]
     self.assert_(subnet_modified.get_createEpoch() ==
                  subnet_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, subnet_queried.get_lastModifiedEpoch()))
예제 #6
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     vm = Vm()
     vm.set_id('VM1')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_save(self.admin_context, vm)
     epoch_after = utils.get_current_epoch_ms()
     vm_queried = healthnmon_db_api.vm_get_by_ids(self.admin_context,
                                                  [vm.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         vm_queried.get_createEpoch()))
     # Check for lastModifiedEpoch and createEpoch after adding VmGlobalSettings
     vm_modified = vm_queried
     test_utils.unset_timestamp_fields(vm_modified)
     vmGlobalSettings = VmGlobalSettings()
     vmGlobalSettings.set_id('VMGS1')
     vmGlobalSettings.set_autoStartAction(Constants.AUTO_START_ENABLED)
     vm_modified.set_vmGlobalSettings(vmGlobalSettings)
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_save(self.admin_context, vm_modified)
     epoch_after = utils.get_current_epoch_ms()
     vm_queried = healthnmon_db_api.vm_get_by_ids(self.admin_context,
                                                  [vm.get_id()])[0]
     self.assert_(
         vm_modified.get_createEpoch() == vm_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after, vm_queried.get_lastModifiedEpoch()))
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vm_queried.get_vmGlobalSettings().get_createEpoch()))
     # Check for lastModifiedEpoch after modifying vm
     vm_modified = vm_queried
     test_utils.unset_timestamp_fields(vm_modified)
     vm_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_save(self.admin_context, vm_modified)
     epoch_after = utils.get_current_epoch_ms()
     vm_queried = healthnmon_db_api.vm_get_by_ids(self.admin_context,
                                                  [vm.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after, vm_queried.get_lastModifiedEpoch()))
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vm_queried.get_vmGlobalSettings().get_lastModifiedEpoch()))
     self.assert_(
         vm_modified.get_createEpoch() == vm_queried.get_createEpoch())
     self.assert_(vm_modified.get_vmGlobalSettings().get_createEpoch() ==
                  vm_queried.get_vmGlobalSettings().get_createEpoch())
예제 #7
0
    def test_timestamp_columns(self):
        """
            Test the time stamp columns createEpoch,
            modifiedEpoch and deletedEpoch
        """
        vm = Vm()
        vm.set_id('VM1')
        # Check for createEpoch
        epoch_before = utils.get_current_epoch_ms()
        healthnmon_db_api.vm_save(self.admin_context, vm)
        epoch_after = utils.get_current_epoch_ms()
        vm_queried = healthnmon_db_api.vm_get_by_ids(
            self.admin_context, [vm.get_id()])[0]
        self.assert_(test_utils.is_timestamp_between(
            epoch_before, epoch_after, vm_queried.get_createEpoch()))

        # Check for lastModifiedEpoch and createEpoch
        # after adding VmGlobalSettings
        vm_modified = vm_queried
        test_utils.unset_timestamp_fields(vm_modified)
        vmGlobalSettings = VmGlobalSettings()
        vmGlobalSettings.set_id('VMGS1')
        vmGlobalSettings.set_autoStartAction(Constants.AUTO_START_ENABLED)
        vm_modified.set_vmGlobalSettings(vmGlobalSettings)
        epoch_before = utils.get_current_epoch_ms()
        healthnmon_db_api.vm_save(self.admin_context, vm_modified)
        epoch_after = utils.get_current_epoch_ms()
        vm_queried = healthnmon_db_api.vm_get_by_ids(
            self.admin_context, [vm.get_id()])[0]
        self.assert_(
            vm_modified.get_createEpoch() == vm_queried.get_createEpoch())
        self.assert_(test_utils.is_timestamp_between(
            epoch_before, epoch_after, vm_queried.get_lastModifiedEpoch()))
        self.assert_(test_utils.is_timestamp_between(
            epoch_before, epoch_after,
            vm_queried.get_vmGlobalSettings().get_createEpoch()))
        # Check for lastModifiedEpoch after modifying vm
        vm_modified = vm_queried
        test_utils.unset_timestamp_fields(vm_modified)
        vm_modified.set_name('changed_name')
        epoch_before = utils.get_current_epoch_ms()
        healthnmon_db_api.vm_save(self.admin_context, vm_modified)
        epoch_after = utils.get_current_epoch_ms()
        vm_queried = healthnmon_db_api.vm_get_by_ids(
            self.admin_context, [vm.get_id()])[0]
        self.assert_(test_utils.is_timestamp_between(
            epoch_before, epoch_after, vm_queried.get_lastModifiedEpoch()))
        self.assert_(test_utils.is_timestamp_between(
            epoch_before, epoch_after,
            vm_queried.get_vmGlobalSettings().get_lastModifiedEpoch()))
        self.assert_(
            vm_modified.get_createEpoch() == vm_queried.get_createEpoch())
        self.assert_(vm_modified.get_vmGlobalSettings().get_createEpoch() ==
                     vm_queried.get_vmGlobalSettings().get_createEpoch())
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     virSw1 = VirtualSwitch()
     virSw1.set_id("VS1_VH1")
     portGrp1 = PortGroup()
     portGrp1.set_id("PG1_VH1")
     virSw1.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virSw1)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_createEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     virsw_modified.set_name("changed_name")
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(virsw_modified.get_portGroups()[0].get_createEpoch() == pg.get_createEpoch())
         self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding portgroup to switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     portGrp2 = PortGroup()
     portGrp2.set_id("PG2_VH1")
     virsw_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context, [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() == virsw_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         if pg.get_id() == portGrp2.get_id():
             self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_createEpoch()))
         else:
             self.assert_(test_utils.is_timestamp_between(epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
예제 #9
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     vmhost = VmHost()
     vmhost.set_id('VH1')
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     vmhost.add_virtualSwitches(virSw1)
     vmhost.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_createEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, virSw.get_createEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     vmhost_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch(
     ) == vmhost_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding switch and portgroup to host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     virSw2 = VirtualSwitch()
     virSw2.set_id('VS2_VH1')
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virSw2.add_portGroups(portGrp2)
     vmhost_modified.add_virtualSwitches(virSw2)
     vmhost_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch(
     ) == vmhost_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         if virSw.get_id() == virSw2.get_id():
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, virSw.get_createEpoch()))
         else:
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after, virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             if pg.get_id() == portGrp2.get_id():
                 self.assert_(test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_createEpoch()))
             else:
                 self.assert_(test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for deletedEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_delete_by_ids(
         self.admin_context, [vmhost_queried.get_id()])
     epoch_after = utils.get_current_epoch_ms()
     deleted_host = healthnmon_db_api.vm_host_get_all_by_filters(
         self.admin_context,
         {"id": vmhost_queried.get_id()}, None, None)[0]
     self.assertTrue(deleted_host.get_deleted())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, deleted_host.get_deletedEpoch()))
     deleted_switches = healthnmon_db_api.\
         virtual_switch_get_all_by_filters(self.admin_context,
                                           {"id": (virSw1.get_id(),
                                                   virSw2.get_id())},
                                           None, None)
     for deleted_switch in deleted_switches:
         self.assertTrue(deleted_switch.get_deleted())
         self.assert_(test_utils.is_timestamp_between(
             epoch_before, epoch_after, deleted_switch.get_deletedEpoch()))
         for deleted_portgrp in deleted_switch.get_portGroups():
             self.assertTrue(deleted_portgrp.get_deleted())
             self.assert_(test_utils.is_timestamp_between(
                 epoch_before, epoch_after,
                 deleted_portgrp.get_deletedEpoch()))
예제 #10
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     vmhost = VmHost()
     vmhost.set_id('VH1')
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     vmhost.add_virtualSwitches(virSw1)
     vmhost.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         vmhost_queried.get_createEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             virSw.get_createEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     vmhost_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch() ==
                  vmhost_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding switch and portgroup to host
     vmhost_modified = vmhost_queried
     test_utils.unset_timestamp_fields(vmhost_modified)
     virSw2 = VirtualSwitch()
     virSw2.set_id('VS2_VH1')
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virSw2.add_portGroups(portGrp2)
     vmhost_modified.add_virtualSwitches(virSw2)
     vmhost_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_save(self.admin_context, vmhost_modified)
     epoch_after = utils.get_current_epoch_ms()
     vmhost_queried = healthnmon_db_api.vm_host_get_by_ids(
         self.admin_context, [vmhost.get_id()])[0]
     self.assert_(vmhost_modified.get_createEpoch() ==
                  vmhost_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             vmhost_queried.get_lastModifiedEpoch()))
     for virSw in vmhost_queried.get_virtualSwitches():
         if virSw.get_id() == virSw2.get_id():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 virSw.get_createEpoch()))
         else:
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after,
                     virSw.get_lastModifiedEpoch()))
         for pg in virSw.get_portGroups():
             if pg.get_id() == portGrp2.get_id():
                 self.assert_(
                     test_utils.is_timestamp_between(
                         epoch_before, epoch_after, pg.get_createEpoch()))
             else:
                 self.assert_(
                     test_utils.is_timestamp_between(
                         epoch_before, epoch_after,
                         pg.get_lastModifiedEpoch()))
     # Check for deletedEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.vm_host_delete_by_ids(self.admin_context,
                                             [vmhost_queried.get_id()])
     epoch_after = utils.get_current_epoch_ms()
     deleted_host = healthnmon_db_api.vm_host_get_all_by_filters(
         self.admin_context, {"id": vmhost_queried.get_id()}, None, None)[0]
     self.assertTrue(deleted_host.get_deleted())
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         deleted_host.get_deletedEpoch()))
     deleted_switches = healthnmon_db_api.virtual_switch_get_all_by_filters(
         self.admin_context, {"id": (virSw1.get_id(), virSw2.get_id())},
         None, None)
     for deleted_switch in deleted_switches:
         self.assertTrue(deleted_switch.get_deleted())
         self.assert_(
             test_utils.is_timestamp_between(
                 epoch_before, epoch_after,
                 deleted_switch.get_deletedEpoch()))
         for deleted_portgrp in deleted_switch.get_portGroups():
             self.assertTrue(deleted_portgrp.get_deleted())
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after,
                     deleted_portgrp.get_deletedEpoch()))
예제 #11
0
 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch, modifiedEpoch and deletedEpoch
     """
     virSw1 = VirtualSwitch()
     virSw1.set_id('VS1_VH1')
     portGrp1 = PortGroup()
     portGrp1.set_id('PG1_VH1')
     virSw1.add_portGroups(portGrp1)
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virSw1)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(
         test_utils.is_timestamp_between(epoch_before, epoch_after,
                                         virsw_queried.get_createEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             pg.get_createEpoch()))
     # Check for lastModifiedEpoch after modifying switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     virsw_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() ==
                  virsw_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         self.assert_(virsw_modified.get_portGroups()[0].get_createEpoch()
                      == pg.get_createEpoch())
         self.assert_(
             test_utils.is_timestamp_between(epoch_before, epoch_after,
                                             pg.get_lastModifiedEpoch()))
     # Check for createdEpoch after adding portgroup to switch
     virsw_modified = virsw_queried
     test_utils.unset_timestamp_fields(virsw_modified)
     portGrp2 = PortGroup()
     portGrp2.set_id('PG2_VH1')
     virsw_modified.add_portGroups(portGrp2)
     epoch_before = utils.get_current_epoch_ms()
     api.virtual_switch_save(self.admin_context, virsw_modified)
     epoch_after = utils.get_current_epoch_ms()
     virsw_queried = api.virtual_switch_get_by_ids(self.admin_context,
                                                   [virSw1.get_id()])[0]
     self.assert_(virsw_modified.get_createEpoch() ==
                  virsw_queried.get_createEpoch())
     self.assert_(
         test_utils.is_timestamp_between(
             epoch_before, epoch_after,
             virsw_queried.get_lastModifiedEpoch()))
     for pg in virsw_queried.get_portGroups():
         if pg.get_id() == portGrp2.get_id():
             self.assert_(
                 test_utils.is_timestamp_between(epoch_before, epoch_after,
                                                 pg.get_createEpoch()))
         else:
             self.assert_(
                 test_utils.is_timestamp_between(
                     epoch_before, epoch_after, pg.get_lastModifiedEpoch()))