18b52a31eSHanoh Haim#!/router/bin/python
28b52a31eSHanoh Haim
38b52a31eSHanoh Haim__copyright__ = "Copyright 2014"
48b52a31eSHanoh Haim
58b52a31eSHanoh Haim
68b52a31eSHanoh Haim
78b52a31eSHanoh Haimimport os
88b52a31eSHanoh Haimimport sys
98b52a31eSHanoh Haimimport nose_outer_packages
108b52a31eSHanoh Haimimport nose
118b52a31eSHanoh Haimfrom nose.plugins import Plugin
128b52a31eSHanoh Haimfrom rednose import RedNose
138b52a31eSHanoh Haimimport termstyle
148b52a31eSHanoh Haimimport control_plane_general_test
158b52a31eSHanoh Haim
168b52a31eSHanoh Haimclass TRexCPConfiguringPlugin(Plugin):
178b52a31eSHanoh Haim    def options(self, parser, env = os.environ):
188b52a31eSHanoh Haim        super(TRexCPConfiguringPlugin, self).options(parser, env)
198b52a31eSHanoh Haim        parser.add_option('-t', '--trex-server', action='store',
208b52a31eSHanoh Haim                            dest='trex_server', default='trex-dan',
21b18e8dc6SHanoh Haim                            help='Specify TRex server hostname. This server will be used to test control-plane functionality.')
228b52a31eSHanoh Haim
238b52a31eSHanoh Haim    def configure(self, options, conf):
248b52a31eSHanoh Haim        if options.trex_server:
258b52a31eSHanoh Haim        	self.trex_server = options.trex_server
268b52a31eSHanoh Haim
278b52a31eSHanoh Haim    def begin (self):
288b52a31eSHanoh Haim        # initialize CTRexCP global testing class, to be used by and accessible all tests
298b52a31eSHanoh Haim        print "assigned trex_server name"
308b52a31eSHanoh Haim        control_plane_general_test.CTRexCP.trex_server = self.trex_server
318b52a31eSHanoh Haim
328b52a31eSHanoh Haim    def finalize(self, result):
338b52a31eSHanoh Haim        pass
348b52a31eSHanoh Haim
358b52a31eSHanoh Haim
368b52a31eSHanoh Haim
378b52a31eSHanoh Haimif __name__ == "__main__":
388b52a31eSHanoh Haim
398b52a31eSHanoh Haim    # setting defaults. By default we run all the test suite
408b52a31eSHanoh Haim    specific_tests    = False
418b52a31eSHanoh Haim    disableLogCapture = False
428b52a31eSHanoh Haim    long_test         = False
438b52a31eSHanoh Haim    report_dir        = "reports"
448b52a31eSHanoh Haim
458b52a31eSHanoh Haim    nose_argv= sys.argv + ['-s', '-v', '--exe', '--rednose', '--detailed-errors']
468b52a31eSHanoh Haim
478b52a31eSHanoh Haim    try:
488b52a31eSHanoh Haim        result = nose.run(argv = nose_argv, addplugins = [RedNose(), TRexCPConfiguringPlugin()])
498b52a31eSHanoh Haim        if (result == True):
508b52a31eSHanoh Haim            print termstyle.green("""
518b52a31eSHanoh Haim                     ..::''''::..
528b52a31eSHanoh Haim                   .;''        ``;.
538b52a31eSHanoh Haim                  ::    ::  ::    ::
548b52a31eSHanoh Haim                 ::     ::  ::     ::
558b52a31eSHanoh Haim                 ::     ::  ::     ::
568b52a31eSHanoh Haim                 :: .:' ::  :: `:. ::
578b52a31eSHanoh Haim                 ::  :          :  ::
588b52a31eSHanoh Haim                  :: `:.      .:' ::
598b52a31eSHanoh Haim                   `;..``::::''..;'
608b52a31eSHanoh Haim                     ``::,,,,::''
618b52a31eSHanoh Haim
628b52a31eSHanoh Haim                   ___  ___   __________
638b52a31eSHanoh Haim                  / _ \/ _ | / __/ __/ /
648b52a31eSHanoh Haim                 / ___/ __ |_\ \_\ \/_/
658b52a31eSHanoh Haim                /_/  /_/ |_/___/___(_)
668b52a31eSHanoh Haim
678b52a31eSHanoh Haim            """)
688b52a31eSHanoh Haim            sys.exit(0)
698b52a31eSHanoh Haim        else:
708b52a31eSHanoh Haim            sys.exit(-1)
718b52a31eSHanoh Haim
728b52a31eSHanoh Haim    finally:
738b52a31eSHanoh Haim        pass