DaanHoogland commented on code in PR #7397: URL: https://github.com/apache/cloudstack/pull/7397#discussion_r1202681262
########## test/integration/smoke/test_vm_schedule.py: ########## @@ -0,0 +1,616 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" P1 tests for VM Schedule +""" +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.base import Account, ServiceOffering, VirtualMachine, VMSchedule +from marvin.lib.common import get_domain, get_zone, get_template +from marvin.lib.utils import cleanup_resources + +# Import Local Modules +from nose.plugins.attrib import attr + +import datetime +import time + + +class Services: + """Test Snapshots Services""" + + def __init__(self): + self.services = { + "account": { + "email": "[email protected]", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "password", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 200, # in MHz + "memory": 256, # In MBs + }, + "disk_offering": { + "displaytext": "Small Disk", + "name": "Small Disk", + "disksize": 1, + }, + "server": { + "displayname": "TestVM", + "username": "root", + "password": "password", + "ssh_port": 22, + "privateport": 22, + "publicport": 22, + "protocol": "TCP", + }, + "mgmt_server": { + "ipaddress": "192.168.100.21", + "username": "root", + "password": "password", + "port": 22, + }, + "templates": { + "displaytext": "Template", + "name": "Template", + "ostype": "CentOS 5.3 (64-bit)", + "templatefilter": "self", + }, + "ostype": "CentOS 5.3 (64-bit)", + } + + +class TestVMSchedule(cloudstackTestCase): + @classmethod + def setUpClass(cls): + cls.testClient = super(TestVMSchedule, cls).getClsTestClient() + cls.api_client = cls.testClient.getApiClient() + + cls._cleanup = [] + + cls.hypervisor = cls.testClient.getHypervisorInfo() + + cls.services = Services().services + # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client) + cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) + cls.services["mode"] = cls.zone.networktype + template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + + cls.services["domainid"] = cls.domain.id + cls.services["server"]["zoneid"] = cls.zone.id + + cls.services["templates"]["ostypeid"] = template.ostypeid + cls.services["zoneid"] = cls.zone.id + + # Create VMs, NAT Rules etc + cls.account = Account.create( + cls.api_client, cls.services["account"], domainid=cls.domain.id + ) + cls._cleanup.append(cls.account) + + cls.services["account"] = cls.account.name + + cls.service_offering = ServiceOffering.create( + cls.api_client, cls.services["service_offering"] + ) + cls._cleanup.append(cls.service_offering) + cls.virtual_machine = VirtualMachine.create( + cls.api_client, + cls.services["server"], + templateid=template.id, + accountid=cls.account.name, + domainid=cls.account.domainid, + serviceofferingid=cls.service_offering.id, + ) + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return Review Comment: ```suggestion def tearDownClass(cls): super(TestVMSchedule, cls).tearDownClass() ``` ########## api/src/main/java/com/cloud/event/EventTypes.java: ########## @@ -111,6 +112,17 @@ public class EventTypes { public static final String EVENT_VM_UNMANAGE = "VM.UNMANAGE"; public static final String EVENT_VM_RECOVER = "VM.RECOVER"; + // VM Schedule + public static final String EVENT_VM_SCHEDULE_CREATE = "VM.SCHEDULE.CREATE"; + public static final String EVENT_VM_SCHEDULE_UPDATE = "VM.SCHEDULE.UPDATE"; + public static final String EVENT_VM_SCHEDULE_DELETE = "VM.SCHEDULE.DELETE"; + + public static final String EVENT_VM_SCHEDULE_START = "VM.SCHEDULE.START"; + public static final String EVENT_VM_SCHEDULE_STOP = "VM.SCHEDULE.STOP"; + public static final String EVENT_VM_SCHEDULE_REBOOT = "VM.SCHEDULE.REBOOT"; + public static final String EVENT_VM_SCHEDULE_FORCE_STOP = "VM.SCHEDULE.FORCE.STOP"; + public static final String EVENT_VM_SCHEDULE_FORCE_REBOOT = "VM.SCHEDULE.FORCE.REBOOT"; Review Comment: same for these, the events are the same as regular operations on VMs irrespective of a schedule doing the actions, are they? ########## api/src/main/java/com/cloud/event/EventTypes.java: ########## @@ -111,6 +112,17 @@ public class EventTypes { public static final String EVENT_VM_UNMANAGE = "VM.UNMANAGE"; public static final String EVENT_VM_RECOVER = "VM.RECOVER"; + // VM Schedule + public static final String EVENT_VM_SCHEDULE_CREATE = "VM.SCHEDULE.CREATE"; + public static final String EVENT_VM_SCHEDULE_UPDATE = "VM.SCHEDULE.UPDATE"; + public static final String EVENT_VM_SCHEDULE_DELETE = "VM.SCHEDULE.DELETE"; + + public static final String EVENT_VM_SCHEDULE_START = "VM.SCHEDULE.START"; Review Comment: is this different than a regular vm start and should it not be the same event? ########## test/integration/smoke/test_vm_schedule.py: ########## @@ -0,0 +1,616 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" P1 tests for VM Schedule +""" +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.base import Account, ServiceOffering, VirtualMachine, VMSchedule +from marvin.lib.common import get_domain, get_zone, get_template +from marvin.lib.utils import cleanup_resources + +# Import Local Modules +from nose.plugins.attrib import attr + +import datetime +import time + + +class Services: + """Test Snapshots Services""" + + def __init__(self): + self.services = { + "account": { + "email": "[email protected]", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "password", + }, + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 200, # in MHz + "memory": 256, # In MBs + }, + "disk_offering": { + "displaytext": "Small Disk", + "name": "Small Disk", + "disksize": 1, + }, + "server": { + "displayname": "TestVM", + "username": "root", + "password": "password", + "ssh_port": 22, + "privateport": 22, + "publicport": 22, + "protocol": "TCP", + }, + "mgmt_server": { + "ipaddress": "192.168.100.21", + "username": "root", + "password": "password", + "port": 22, + }, + "templates": { + "displaytext": "Template", + "name": "Template", + "ostype": "CentOS 5.3 (64-bit)", + "templatefilter": "self", + }, + "ostype": "CentOS 5.3 (64-bit)", + } + + +class TestVMSchedule(cloudstackTestCase): + @classmethod + def setUpClass(cls): + cls.testClient = super(TestVMSchedule, cls).getClsTestClient() + cls.api_client = cls.testClient.getApiClient() + + cls._cleanup = [] + + cls.hypervisor = cls.testClient.getHypervisorInfo() + + cls.services = Services().services + # Get Zone, Domain and templates + cls.domain = get_domain(cls.api_client) + cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) + cls.services["mode"] = cls.zone.networktype + template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"]) + + cls.services["domainid"] = cls.domain.id + cls.services["server"]["zoneid"] = cls.zone.id + + cls.services["templates"]["ostypeid"] = template.ostypeid + cls.services["zoneid"] = cls.zone.id + + # Create VMs, NAT Rules etc + cls.account = Account.create( + cls.api_client, cls.services["account"], domainid=cls.domain.id + ) + cls._cleanup.append(cls.account) + + cls.services["account"] = cls.account.name + + cls.service_offering = ServiceOffering.create( + cls.api_client, cls.services["service_offering"] + ) + cls._cleanup.append(cls.service_offering) + cls.virtual_machine = VirtualMachine.create( + cls.api_client, + cls.services["server"], + templateid=template.id, + accountid=cls.account.name, + domainid=cls.account.domainid, + serviceofferingid=cls.service_offering.id, + ) + return + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + # Clean up, terminate the created instance, volumes and snapshots + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return Review Comment: ```suggestion def tearDown(self): super(TestVMSchedule, self).tearDown() ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
