Ejemplo n.º 1
0
    def testClusterFilesStandard(self):
        '''Test cluster with non-enterprise version specified'''
        #print '++++++++++ DEBUG: starting testClusterFilesStandard'
        mgr = ClusterMgr()

        s = """{
            "name" : "a-cluster",
            "idbversion" : "4.0.0-1", 
            "boxtype" : "cal-precise64",
            "enterprise" : false,
            "rolespec" : {
                "pm" : {
                    "count" : 2,
                    "memory" : 1024,
                    "dbroots_per" : 1
                },
                "um" : {
                    "count" : 1,
                    "memory" : 2048
                }
              }
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('teststd',cfg,'vagrant')
        ref_file = '%s/teststd-Vagrantfile' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))

        self.assertEqual( mgr.list_clusters()[0][0], 'teststd' )

        c.destroy_files_only()
Ejemplo n.º 2
0
    def testClusterFilesEMinVMpm1(self):
        '''Test cluster with EM present'''
        #print '++++++++++ DEBUG: starting testClusterFilesEMinVM'
        mgr = ClusterMgr()

        s = """{
            "name" : "em-cluster",
            "idbversion" : "4.5.0-1", 
            "binary" : true,
            "boxtype" : "cal-precise64",
            "em" : { "present" : true, "invm" : true, "role" : "pm1" },
            "rolespec" : {
                "pm" : {
                    "count" : 2,
                    "memory" : 1024,
                    "dbroots_per" : 1
                }
              }
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('testeminvmpm1',cfg,'vagrant')
        ref_file = '%s/testeminvmpm1-Vagrantfile' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))

        self.assertEqual( mgr.list_clusters()[0][0], 'testeminvmpm1' )

        c.destroy_files_only()
Ejemplo n.º 3
0
    def testDatdup(self):
        '''Test cluster with datdup specified'''
        #print '++++++++++ DEBUG: starting testDatdup'
        mgr = ClusterMgr()

        s = """{
            "name" : "a-cluster",
            "idbversion" : "4.0.0-0", 
            "boxtype" : "cal-precise64",
            "datdup" : true,
            "rolespec" : {
                "pm" : {
                    "count" : 4,
                    "memory" : 1024,
                    "dbroots_per" : 1
                },
                "um" : {
                    "count" : 1,
                    "memory" : 2048
                }
              }
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('testdatdup',cfg,'vagrant')
        self.assertEqual( mgr.list_clusters()[0][0], 'testdatdup' )

        mgr.destroy(c)
Ejemplo n.º 4
0
    def testClusterFilesUpgrade(self):
        '''Test cluster with upgrade version specified'''
        #print '++++++++++ DEBUG: starting testClusterFilesUpgrade'
        mgr = ClusterMgr()

        s = """{
            "name" : "a-cluster",
            "idbversion" : "3.5.1-5", 
            "boxtype" : "cal-precise64",
            "upgrade" : "Latest",
            "rolespec" : {
                "pm" : {
                    "count" : 4,
                    "memory" : 1024,
                    "dbroots_per" : 1
                },
                "um" : {
                    "count" : 1,
                    "memory" : 2048
                }
              }
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('testupg',cfg,'vagrant')
        ref_file = '%s/testupg-Vagrantfile' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))
        ref_file = '%s/testupg-postconfigure.in' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._pfile))

        self.assertEqual( mgr.list_clusters()[0][0], 'testupg' )

        c.destroy_files_only()
Ejemplo n.º 5
0
    def testClusterFiles22(self):
        '''Test cluster with version 2.2'''
        #print '++++++++++ DEBUG: starting testClusterFiles22'
        mgr = ClusterMgr()

        s = """{
            "name" : "a-cluster",
            "idbversion" : "2.2.11-1", 
            "boxtype" : "cal-precise64",
            "rolespec" : {
                "pm" : {
                    "count" : 2,
                    "dbroots_per" : 1
                }
              }
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('test22',cfg,'vagrant')
        ref_file = '%s/test22-Vagrantfile' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))
        ref_file = '%s/test22-postconfigure.in' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._pfile))

        self.assertEqual( mgr.list_clusters()[0][0], 'test22' )

        c.destroy_files_only()
Ejemplo n.º 6
0
 def testClusterFilesNonRoot(self):        
     #print '++++++++++ DEBUG: starting testClusterFilesNonRoot'
     mgr = ClusterMgr()
     
     c = mgr.alloc_new('test1',self._nonrootcfg,'vagrant')
     ref_file = '%s/testnonroot-Vagrantfile' % os.path.dirname(__file__)
     self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))
     ref_file = '%s/testnonroot-postconfigure.in' % os.path.dirname(__file__)
     self.assertTrue( testutils.file_compare(ref_file, c._vmi._pfile))
     
     self.assertEqual( mgr.list_clusters()[0][0], 'test1' )
     
     c.destroy_files_only()
Ejemplo n.º 7
0
def main(argv=None):
    try:
        opts, args = getopt.getopt(sys.argv[1:], "pu", [])
    except getopt.GetoptError as err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)

    killprocs = False
    for o, a in opts:
        if o == "-p":
            killprocs = True
        elif o == "-u":
            import autooam.test.test_common
            utils.syscall_cb = mysyscb
        else:
            assert False, "unhandled option"

    if killprocs:
        kill_autorun_procs()
        
    # first get the list of registered vms from virtualbox
    vms = get_vbox_vms()

    mgr = ClusterMgr()    
    ids = Set()
    for c in mgr.list_clusters():
        ids.add(c[1])
        
    for vm in vms:
        print "Checking vm %s" % vm[0],
        if vm[0] == "<inaccessible>":
            print "...Orphaned, Deleting"
            cmd = "vboxmanage unregistervm %s --delete" % vm[1]
            print "Issuing: %s" % cmd
            utils.syscall_log(cmd)
        else:
            _id = vm[0].split('_')[0]
            if not _id in ids:
                print "...Orphaned, Deleting"
                cmd = "vboxmanage unregistervm %s --delete" % vm[0]
                print "Issuing: %s" % cmd
                utils.syscall_log(cmd)
            else:
                print "...Ok"
Ejemplo n.º 8
0
    def testClusterFilesHadoop(self):
        '''Test cluster with hadoop specified'''
        #print '++++++++++ DEBUG: starting testClusterFilesHadoop'
        mgr = ClusterMgr()

        s = """{
            "name" : "a-cluster",
            "idbversion" : "Latest", 
            "boxtype" : "cal-precise64",
            "rolespec" : {
                "pm" : {
                    "count" : 2,
                    "memory" : 1024,
                    "dbroots_per" : 1
                },
                "um" : {
                    "count" : 1,
                    "memory" : 2048
                }
              },
           "hadoop" : {
            "instance-templates" : "1 hadoop-namenode+hadoop-jobtracker,2 hadoop-datanode+hadoop-tasktracker"
              }              
            }
            """
        cfg = ConfigSpec(s)

        c = mgr.alloc_new('testhadoop',cfg,'vagrant')
        ref_file = '%s/testhadoop-Vagrantfile' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._vfile))
        ref_file = '%s/testhadoop-postconfigure.in' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, c._vmi._pfile))

        self.assertEqual( mgr.list_clusters()[0][0], 'testhadoop' )

        c.destroy_files_only()
Ejemplo n.º 9
0
class ClusterCmd(object):
    def __init__(self):
        self._mgr = ClusterMgr()

    def main(self, argv=None):
        if not argv:
            argv = sys.argv

        try:
            opts, args = getopt.getopt(argv[1:], "u", [])
        except getopt.GetoptError as err:
            # print help information and exit:
            print str(err)  # will print something like "option -a not recognized"
            self.usage()
            sys.exit(2)

        for o, a in opts:
            if o == "-u":
                import autooam.test.test_common

                # reinitialize this to pickup debug db
                self._mgr = ClusterMgr()
            else:
                assert False, "unhandled option"

        cmdaction = {
            "list": self.listclusters,
            "start": self.start,
            "poweron": self.poweron,
            "poweroff": self.poweroff,
            "pause": self.pause,
            "resume": self.resume,
            "destroy": self.destroy,
            "shell": self.shell,
            "show": self.show,
            "forceclean": self.forceclean,
            "run": self.run,
            "attach": self.attach,
        }

        if len(args) < 1 or not cmdaction.has_key(args[0]):
            self.usage()

        return cmdaction[args[0]](args[1:])

    def usage(self):
        print """usage: clustercmd [-u] command [command options] ...
        
            -u  : enable unit-test mode
            
        Supported command options:
            list
                : list all clusters
            start cluster
                : start the cluster with name <cluster>
            poweron cluster
                : powers on the cluster with name <cluster>
            poweroff cluster
                : powers off the cluster with name <cluster>
            pause cluster
                : pauses the cluster with name <cluster>
            resume cluster
                : resumes the cluster with name <cluster>
            destroy <regex>
                : destroy any clusters with name  or ID matching <regex>
            shell cluster node cmd
                : run 'cmd' on node 'node' in the named cluster
            show cluster
                : show details for the cluster with name <cluster>            
            forceclean cluster
                : destroy and clean cluster, even if in inconsistent state
            run cluster test
                : run the test suite named 'test' on <cluster>            
            attach cluster emhost emport
                : attempt an attach from EM server <emhost>:<emport> to <cluster>            
        """
        sys.exit(1)

    def listclusters(self, args):
        print "Clusters: (name, id)"
        for c in self._mgr.list_clusters():
            sync = "ok"
            try:
                cluster = self._mgr.attach(c[0])
                sync = "ok,%s" % cluster.status()
            except Exception, err:
                sync = "invalid (%s),n/a" % err
            print "\t(%s,%s,%s)" % (c[0], c[1], sync)
        return 0