Revision 99d41650 snf-cyclades-app/synnefo/tools/burnin.py

b/snf-cyclades-app/synnefo/tools/burnin.py
81 81
log = logging.getLogger("burnin")
82 82
log.setLevel(logging.INFO)
83 83

  
84

  
85 84
class UnauthorizedTestCase(unittest.TestCase):
86 85
    def test_unauthorized_access(self):
87 86
        """Test access without a valid token fails"""
88 87
        falseToken = '12345'
89 88
        conf = Config()
90 89
        conf.set('compute_token', falseToken)
90
        c=ComputeClient(conf)
91 91

  
92 92
        with self.assertRaises(ClientError) as cm:
93 93
            c.list_servers()
......
407 407
        """Test server metadata keys are set based on image metadata"""
408 408
        servermeta = self.client.get_server_metadata(self.serverid)
409 409
        imagemeta = self.client.get_image_metadata(self.imageid)
410
        self.assertEqual(servermeta["os"], imagemeta["os"])
410
        self.assertEqual(servermeta["OS"], imagemeta["os"])
411 411

  
412 412
    def test_003_server_becomes_active(self):
413 413
        """Test server becomes ACTIVE"""
......
599 599
                raise Exception("Cannot handle msg: %s" % msg)
600 600

  
601 601

  
602

  
602 603
def _run_cases_in_parallel(cases, fanout=1, runner=None):
603 604
    """Run instances of TestCase in parallel, in a number of distinct processes
604 605

  
......
708 709
                      metavar="TIMEOUT",
709 710
                      help="Wait SECONDS seconds for a server action to " \
710 711
                           "complete, then the test is considered failed",
711
                      default=20)
712
                      default=50)
712 713
    parser.add_option("--build-warning",
713 714
                      action="store", type="int", dest="build_warning",
714 715
                      metavar="TIMEOUT",
......
775 776

  
776 777
        if opts.force_imageid != 'all':
777 778
            try:
778
                opts.force_imageid = int(opts.force_imageid)
779
                opts.force_imageid = str(opts.force_imageid)
779 780
            except ValueError:
780 781
                print >>sys.stderr, "Invalid value specified for --image-id." \
781 782
                                    "Use a numeric id, or `all'."
......
819 820
    # Run them: FIXME: In parallel, FAILEARLY, catchbreak?
820 821
    #unittest.main(verbosity=2, catchbreak=True)
821 822

  
822
    runner = unittest.TextTestRunner(verbosity=2, failfast=not opts.nofailfast)
823
    # The following cases run sequentially
824
    seq_cases = [UnauthorizedTestCase, FlavorsTestCase, ImagesTestCase]
825
    _run_cases_in_parallel(seq_cases, fanout=3, runner=runner)
826

  
827
    # The following cases run in parallel
828
    par_cases = []
829

  
830
    if opts.force_imageid == 'all':
831
        test_images = DIMAGES
832
    else:
833
        test_images = filter(lambda x: x["id"] == opts.force_imageid, DIMAGES)
834

  
823
    test_images = filter(lambda x: x["id"] == opts.force_imageid, DIMAGES)
835 824
    for image in test_images:
836
        imageid = image["id"]
825
        imageid = str(image["id"])
826
        flavorid = choice([f["id"] for f in DFLAVORS if f["disk"] >= 20])
837 827
        imagename = image["name"]
838
        if opts.force_flavorid:
839
            flavorid = opts.force_flavorid
840
        else:
841
            flavorid = choice([f["id"] for f in DFLAVORS if f["disk"] >= 20])
842 828
        personality = None   # FIXME
843 829
        servername = "%s%s for %s" % (SNF_TEST_PREFIX, TEST_RUN_ID, imagename)
844 830
        is_windows = imagename.lower().find("windows") >= 0
845
        case = _spawn_server_test_case(imageid=str(imageid), flavorid=flavorid,
831
        case = _spawn_server_test_case(imageid=imageid, flavorid=flavorid,
846 832
                                       imagename=imagename,
847 833
                                       personality=personality,
848 834
                                       servername=servername,
......
851 837
                                       build_warning=opts.build_warning,
852 838
                                       build_fail=opts.build_fail,
853 839
                                       query_interval=opts.query_interval)
854
        par_cases.append(case)
855 840

  
856
    _run_cases_in_parallel(par_cases, fanout=opts.fanout, runner=runner)
841

  
842
    seq_cases = [UnauthorizedTestCase, FlavorsTestCase, ImagesTestCase, case]
843

  
844
    for case in seq_cases:
845
        suite = unittest.TestLoader().loadTestsFromTestCase(case)
846
        unittest.TextTestRunner(verbosity=2).run(suite)
847

  
848
    
849

  
850
    # # The Following cases run sequentially
851
    # seq_cases = [UnauthorizedTestCase, FlavorsTestCase, ImagesTestCase]
852
    # _run_cases_in_parallel(seq_cases, fanout=3, runner=runner)
853

  
854
    # # The following cases run in parallel
855
    # par_cases = []
856

  
857
    # if opts.force_imageid == 'all':
858
    #     test_images = DIMAGES
859
    # else:
860
    #     test_images = filter(lambda x: x["id"] == opts.force_imageid, DIMAGES)
861

  
862
    # for image in test_images:
863
    #     imageid = image["id"]
864
    #     imagename = image["name"]
865
    #     if opts.force_flavorid:
866
    #         flavorid = opts.force_flavorid
867
    #     else:
868
    #         flavorid = choice([f["id"] for f in DFLAVORS if f["disk"] >= 20])
869
    #     personality = None   # FIXME
870
    #     servername = "%s%s for %s" % (SNF_TEST_PREFIX, TEST_RUN_ID, imagename)
871
    #     is_windows = imagename.lower().find("windows") >= 0
872
    #     case = _spawn_server_test_case(imageid=str(imageid), flavorid=flavorid,
873
    #                                    imagename=imagename,
874
    #                                    personality=personality,
875
    #                                    servername=servername,
876
    #                                    is_windows=is_windows,
877
    #                                    action_timeout=opts.action_timeout,
878
    #                                    build_warning=opts.build_warning,
879
    #                                    build_fail=opts.build_fail,
880
    #                                    query_interval=opts.query_interval)
881
    #     par_cases.append(case)
882

  
883
    # _run_cases_in_parallel(par_cases, fanout=opts.fanout, runner=runner)
857 884

  
858 885
if __name__ == "__main__":
859 886
    sys.exit(main())

Also available in: Unified diff