def test_compile(self): """ This test checks that the components in the compiled manifest are correct. """ # Compile the manifest compiler = rift.vcs.compiler.ManifestCompiler() manifest = compiler.compile(self.sysinfo) # Define the list of component types that expected and the oreder in # which they are expected. expected_types = (rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaCluster, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaCluster, rift.vcs.manifest.RaColony) # Define a generator over the components in the manifest components = ( component for colony in manifest.components for component in rift.vcs.core.component_iterator(colony)) # Iterate over the components and the expected types and check that the # match up. for component, expected in zip(components, expected_types): self.assertEqual(type(component), expected)
def DISABLED_test_find_ancestor(self): # Create a system that contains a colony, a cluster, and 2 virtual # machines. cli = rift.vcs.vms.CliVM() mgmt = rift.vcs.vms.MgmtVM() cluster = rift.vcs.Cluster( name="test.cluster", virtual_machines=[cli, mgmt], ) colony = rift.vcs.Colony( name="test.colony", clusters=[cluster], ) sysinfo = rift.vcs.SystemInfo( mode='ethsim', collapsed=True, colonies=[colony], ) # Compile the manifest compiler = rift.vcs.compiler.LegacyManifestCompiler() _, manifest = compiler.compile(sysinfo) # "" the CLI, colony, and cluster components cli = manifest.find_by_class(rift.vcs.manifest.RaCliProc) colony = manifest.find_by_class(rift.vcs.manifest.RaColony) cluster = manifest.find_by_class(rift.vcs.manifest.RaCluster) # Verify that the enclosing function for colonies and clusters return # the correct components self.assertTrue(manifest.find_enclosing_colony(cli) is colony) self.assertTrue(manifest.find_enclosing_cluster(cli) is cluster)
def test_compile(self): """ This test checks that the components in the compiled manifest are correct. """ # Compile the manifest compiler = rift.vcs.compiler.ManifestCompiler() manifest = compiler.compile(self.sysinfo) # Define the list of component types that expected and the oreder in # which they are expected. expected_types = ( rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaCluster, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaVm, rift.vcs.manifest.RaCluster, rift.vcs.manifest.RaColony) # Define a generator over the components in the manifest components = (component for colony in manifest.components for component in rift.vcs.core.component_iterator(colony)) # Iterate over the components and the expected types and check that the # match up. for component, expected in zip(components, expected_types): self.assertEqual(type(component), expected)
def test_webserver_compilation(self): """ This test checks that the webserver tasklet is correctly handled by the legacy compiler. """ # There should be one uagent and one webserver self.assertEqual(1, len(self.sysinfo.list_by_class(rift.vcs.uAgentTasklet))) self.assertEqual(1, len(self.sysinfo.list_by_class(rift.vcs.Webserver))) # Compile the manfiest compiler = rift.vcs.compiler.LegacyManifestCompiler() _, manifest = compiler.compile(self.sysinfo) # The webserver is the one of the 2 native processes on the VM colony = manifest.components[0] native = rift.vcs.core.list_by_class(colony, rift.vcs.manifest.RaNativeProcess) self.assertEqual(3, len(native))
def test_webserver_compilation(self): """ This test checks that the webserver tasklet is correctly handled by the legacy compiler. """ # There should be one uagent and one webserver self.assertEqual( 1, len(self.sysinfo.list_by_class(rift.vcs.uAgentTasklet))) self.assertEqual(1, len(self.sysinfo.list_by_class(rift.vcs.Webserver))) # Compile the manfiest compiler = rift.vcs.compiler.LegacyManifestCompiler() _, manifest = compiler.compile(self.sysinfo) # The webserver is the one of the 2 native processes on the VM colony = manifest.components[0] native = rift.vcs.core.list_by_class(colony, rift.vcs.manifest.RaNativeProcess) self.assertEqual(3, len(native))
def generate_manifest(self): test_vm = TestWare.TestVM(ip="127.0.0.1") test_vm.lead = True colony = rift.vcs.core.Colony(name='top', uid=1) colony.append(test_vm) sysinfo = rift.vcs.core.SystemInfo( mode='ethsim', collapsed=True, zookeeper=rift.vcs.manifest.RaZookeeper(zake=True, master_ip="127.0.0.1"), colonies=[colony], multi_broker=True, multi_dtsrouter=False, ) # Compile the manifest compiler = rift.vcs.compiler.LegacyManifestCompiler() _, manifest = compiler.compile(sysinfo) vcs = rift.vcs.api.RaVcsApi() vcs.manifest_generate_xml(manifest, self.manifest_path)
def DISABLED_test(self): def count_components(manifest, type_name): count = 0 for component in manifest.inventory.component: if component.HasField(type_name): count += 1 return count # Create a system that contains a colony, a cluster, and 2 virtual # machines. cli = rift.vcs.vms.CliVM() mgmt = rift.vcs.vms.MgmtVM() cluster = rift.vcs.Cluster( name="test.cluster", virtual_machines=[cli, mgmt], ) colony = rift.vcs.Colony( name="test.colony", clusters=[cluster], ) sysinfo = rift.vcs.SystemInfo( mode='ethsim', collapsed=True, colonies=[colony], ) # Adding a new tasklet cli.add_tasklet(rift.vcs.DtsPerfTasklet()) # Check that the system has a DTS router tasklet and 2 virtual # machines. self.assertEqual(1, len(sysinfo.list_by_class(rift.vcs.DtsPerfTasklet))) self.assertEqual(2, len(sysinfo.list_by_class(rift.vcs.VirtualMachine))) # Compile the manifest into a protobuf compiler = rift.vcs.compiler.LegacyManifestCompiler() manifest = compiler.compile(sysinfo)[1].as_pb() # Check that the manifest has the expected number of tasklets and # virtual machines. self.assertEqual(7, count_components(manifest, 'rwtasklet')) self.assertEqual(2, count_components(manifest, 'rwvm')) # Add anpother of same tasklet and a virtual machine to the system cli.add_tasklet(rift.vcs.DtsPerfTasklet()) cluster.add_virtual_machine(rift.vcs.VirtualMachine(name="foo")) # There should now be 2 instances of the DtsRouterTasklet and 3 virtual # machines. self.assertEqual(2, len(sysinfo.list_by_class(rift.vcs.DtsPerfTasklet))) self.assertEqual(3, len(sysinfo.list_by_class(rift.vcs.VirtualMachine))) # Compile the manifest into a protobuf manifest = compiler.compile(sysinfo)[1].as_pb() # Check that the number of tasklet components unchanged, but the number # of virtual machine components has increased by 1. self.assertEqual(7, count_components(manifest, 'rwtasklet')) self.assertEqual(3, count_components(manifest, 'rwvm'))
def main(): MASTER="10.0.23.169" VM1="10.0.23.175" VM2="10.0.23.143" collapsed = False MASTER='10.0.106.26' VM1='10.0.106.13' VM2='10.0.106.25' VM3='10.0.106.27' if '-l' in sys.argv: MASTER='127.0.0.1' VM1='127.0.0.1' VM2='127.0.0.1' VM3='127.0.0.2' collapsed = True if '-g' in sys.argv: gdb_enabled = True logging.basicConfig(format='%(asctime)-15s %(levelname)s %(message)s') logging.getLogger().setLevel(logging.DEBUG) colony = rift.vcs.core.Colony(name='top', uid=1) #gen = rift.vcs.core.Cluster(name='gen') #colony.add_cluster(gen) #vm3 = GenVM(ip=VM2) #vm3.leader = True #gen.add_virtual_machine(vm3) #vm4 = Gen2VM(ip=VM3) #gen.add_virtual_machine(vm4) mgmt = rift.vcs.core.Cluster(name='mgmt') colony.add_cluster(mgmt) vm2 = MgmtVM(ip=VM1) vm2.leader = True mgmt.add_virtual_machine(vm2) lead = CliVM(ip=MASTER) lead.leader = True colony.append(lead) multid=False if '-m' in sys.argv: multid=True # Construct the system sysinfo = rift.vcs.core.SystemInfo( mode='ethsim', collapsed=collapsed, zookeeper=rift.vcs.manifest.RaZookeeper(zake=collapsed, master_ip=MASTER), colonies=[colony], multi_broker=True, multi_dtsrouter=multid, ) # Compile the manifest compiler = rift.vcs.compiler.LegacyManifestCompiler() try: sysinfo_ret, manifest = compiler.compile(sysinfo) except: sysinfo_ret, manifest = compiler.compile(sysinfo, "cli_rwfpath_schema_listing.txt") pass pwd = os.getcwd() os.chdir(os.environ['RIFT_INSTALL']) manifest_file = os.path.join(pwd, "manifest.xml") vcs = rift.vcs.api.RaVcsApi() vcs.manifest_generate_xml(manifest, manifest_file)
def main(): MASTER = "10.0.202.246" VM1 = "10.0.202.26" VM2 = "10.0.106.26" VM3 = "10.0.106.27" collapsed = False mgmt_ip_list = [VM2, VM3] mgmt_ip_list = [MASTER, VM1] start = False if '-l' in sys.argv: MASTER = '127.0.0.1' VM1 = '127.0.0.1' VM2 = '127.0.0.1' VM3 = '127.0.0.2' collapsed = True start = True mgmt_ip_list = [MASTER] if '-g' in sys.argv: gdb_enabled = True logging.basicConfig(format='%(asctime)-15s %(levelname)s %(message)s') logging.getLogger().setLevel(logging.DEBUG) colony = rift.vcs.core.Colony(name='top', uid=1) #gen = rift.vcs.core.Cluster(name='gen') #colony.add_cluster(gen) #vm3 = GenVM(ip=VM2) #vm3.leader = True #gen.add_virtual_machine(vm3) #vm4 = Gen2VM(ip=VM3) #gen.add_virtual_machine(vm4) #mgmt = rift.vcs.core.Cluster(name='mgmt') #colony.add_cluster(mgmt) vm2 = MgmtVM(ip=MASTER, start=start) vm2.leader = True #mgmt.add_virtual_machine(vm2) colony.append(vm2) lead = CliVM(ip=VM1, start=start) colony.append(lead) multid = False if '-m' in sys.argv: multid = True # Construct the system sysinfo = rift.vcs.core.SystemInfo( mode='ethsim', collapsed=collapsed, zookeeper=rift.vcs.manifest.RaZookeeper(zake=collapsed, master_ip=MASTER), colonies=[colony], multi_broker=True, multi_dtsrouter=True, mgmt_ip_list=mgmt_ip_list, ) # Compile the manifest compiler = rift.vcs.compiler.LegacyManifestCompiler() try: sysinfo_ret, manifest = compiler.compile(sysinfo) except: sysinfo_ret, manifest = compiler.compile( sysinfo, "cli_rwfpath_schema_listing.txt") pass pwd = os.getcwd() os.chdir(os.environ['RIFT_INSTALL']) manifest_file = os.path.join(pwd, "manifest.xml") vcs = rift.vcs.api.RaVcsApi() vcs.manifest_generate_xml(manifest, manifest_file)