Exemple #1
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()
Exemple #2
0
    def test1(self):
        #print '++++++++++ DEBUG: starting test1'
        s = """{
            "name" : "a-cluster",
            "idbversion" : "Latest", 
            "boxtype" : "cal-precise64",
            "rolespec" : {
                "pm" : {
                    "count" : 4,
                    "memory" : 1024,
                    "dbroots_per" : 1
                }
              },
            "hadoop"     : {
              "instance-templates" : "1 hadoop-namenode+hadoop-jobtracker,2 hadoop-datanode+hadoop-tasktracker"
              }
            }
            """
        mgr = ClusterMgr()
        
        c = mgr.alloc_new('my-clustername',ConfigSpec(s),'vagrant')
        w = WhirrConfigWriter(c)
        w.write_config(self._basedir)
        ref_file = '%s/testwhirr-props' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, self._propcmp))
        ref_file = '%s/testwhirr-nodes' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, self._nodecmp))

        mgr.destroy(c)
Exemple #3
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()
Exemple #4
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()
Exemple #5
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()
Exemple #6
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()
Exemple #7
0
    def testDebugLoggedSyscall(self):
        global myret, mydata, mycmd, myscyscb
        utils.syscall_cb = mysyscb

        logfile = "loggedsyscall"
        os.system("rm -f %s" % logfile)

        myret = 0
        mydata = "foo.py\n"
        ret = utils.syscall_log("ls foo.py", logfile)[0]
        self.assertEqual(ret, 0)
        
        myret = 1
        mydata = ""
        ret = utils.syscall_log("grep notthere setup.py", logfile)[0]
        self.assertEqual(ret, 1)
        
        myret = 1
        mydata = "cat: /etc/foodog: No such file or directory\n"
        ret = utils.syscall_log("cat /etc/foodog", logfile)[0]
        self.assertEqual(ret, 1)

        ref_file = '%s/test2-loggedsyscall' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, logfile))
        # clean up after ourself
        os.system("rm -f %s" % logfile)
        
        utils.syscall_cb = None
Exemple #8
0
    def testBasic(self):
        #print '++++++++++ DEBUG: starting testBasic'
        if True:
            # put in a code block so that TestReport closed before we validate
            tr = TestReport('/tmp/trtest.log')
    
            mgr = ClusterMgr()
            
            cfg1 = configs.multi_1um_2pm('3.5.1-5')
            cfg1['boxtype'] = 'cal-precise64'
    
            c = mgr.alloc_new('test-report',cfg1,'vagrant')
    
            tr.new_config(c)
                            
            ts = TestSuite('my001','a unit test test suite')
            t = datetime.now()
            res = TestResult( t, t, True)
            tr.new_result(ts, res)
    
            ts = TestSuite('my002','another test suite')
            res = TestResult( t, t, False)
            tr.new_result(ts, res)
            
            mgr.destroy(c)
            # have to explicitly call this to make sure the file is closed
            tr.finish()

        ref_file = '%s/test1-testlog' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, '/tmp/trtest.log'))
Exemple #9
0
    def testPmQuery(self):
        '''Test cluster with PMQuery'''
        #print '++++++++++ DEBUG: starting testPMQuery'
        mgr = ClusterMgr()

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

        c.destroy_files_only()
Exemple #10
0
    def testSuccess(self):
        p = PlaybookMgr( 'testbook' )
        p.write_inventory( 'testinv', { 'all' : ['foo.calpont.com', 'bar.calpont.com'] } )
        
        inv = p.read_inventory( 'testinv' )
        self.assertEquals(inv['all'][0], 'foo.calpont.com')
        self.assertEquals(inv['all'][1], 'bar.calpont.com')
        
        ref_file = '%s/test_testinv' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, '%s/testinv' % p.get_rootdir()))
        
        p.config_ssh( 'root', 'some_key_data1234567890' )

        ref_file = '%s/test_ansible.cfg' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, '%s/ansible.cfg' % p.get_rootdir()))

        ref_file = '%s/test_private_key' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, '%s/.ssh/private_key' % p.get_rootdir()))
        
        
        shutil.rmtree( p.get_rootdir() )
Exemple #11
0
    def testLoggedSyscall(self):
        logfile = "loggedsyscall"
        os.system("rm -f %s" % logfile)
        ret = utils.syscall_log("ls setup.py", logfile)[0]
        self.assertEqual(ret, 0)
        ret = utils.syscall_log("grep notthere setup.py", logfile)[0]
        self.assertEqual(ret, 1)
        ret = utils.syscall_log("cat /etc/foobar", logfile)[0]
        self.assertEqual(ret, 1)

        ref_file = '%s/test1-loggedsyscall' % os.path.dirname(__file__)
        self.assertTrue( testutils.file_compare(ref_file, logfile))
        # clean up after ourself
        os.system("rm -f %s" % logfile)
Exemple #12
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()