Beispiel #1
0
    def runTest(self):
        service_output_filename = os.path.join(self._folder,
                                               self.service_name + '.log')

        self.add_http(self.service_name)
        service_cmd = [self._binaries[self.service_name]]
        service_cmd += self.http_settings(self.service_name)
        service_cmd += [
            '--' + k + '=' + v for k, v in self.extra_args.iteritems()
        ]

        procs = ProcSet()
        service_output = open(service_output_filename, 'w')
        print(' '.join(service_cmd), file=service_output)
        service_output.flush()
        procs.process(self.service_name,
                      service_cmd,
                      stdout=service_output,
                      stderr=subprocess.STDOUT,
                      default=True)

        # If requested, block for upto 10 seconds for the process to start responding to commands
        if self.wait_until_responsive:
            result = self.command(self.service_name,
                                  'meta.commands',
                                  retries=40,
                                  wait=.25)
            if result is None:
                self.fail('Server never became responsive to HTTP commands')

        # Defer to the implementation for sending and checking test
        # commands. Catch all errors so we can make sure we cleanup the
        # processes properly and report crashes, etc.
        try:
            self.testCommands(procs)
        except:
            self.fail(msg='Uncaught exception during test:\n' +
                      traceback.format_exc())

        # The implementation should know whether things are shutting
        # down cleanly. We just make sure we clean up aggressively if
        # necessary.
        if not procs.done():
            procs.wait(until=self.duration,
                       killAt=self.duration,
                       output=self._output)

        # Print a notification if we had to kill this process
        if procs.killed():
            self.fail('Timed out')

        service_output.close()
        self.report_files = {self.service_name: service_output_filename}

        self.assertLogErrorFree(service_output_filename)
        self.assertReturnCode(procs.returncode())
Beispiel #2
0
    def runTest(self, outputPath, binPath, cppohBinName, spaceBinName, output=sys.stdout):
        service_output_filename = os.path.join(outputPath, self.service_name + '.log')

        self.add(self.service_name)
        if self.service_name == 'space':
            service_bin = spaceBinName
        elif self.service_name == 'cppoh':
            service_bin = cppohBinName
        service_cmd = [os.path.join(binPath, service_bin)]
        service_cmd += self.http_settings(self.service_name)
        service_cmd += ['--' + k + '=' + v for k,v in self.extra_args.iteritems()]

        procs = ProcSet()
        service_output = open(service_output_filename, 'w')
        print(' '.join(service_cmd), file=service_output)
        service_output.flush()
        procs.process(service_cmd, stdout=service_output, stderr=subprocess.STDOUT, default=True)

        # If requested, block for upto 10 seconds for the process to start responding to commands
        if self.wait_until_responsive:
            result = self.command(self.service_name, 'meta.commands', retries=40, wait=.25, output=output)
            if result is None: self.fail('Server never became responsive to HTTP commands')

        # Defer to the implementation for sending and checking test
        # commands. Catch all errors so we can make sure we cleanup the
        # processes properly and report crashes, etc.
        try:
            self.testCommands(procs, output=output)
        except:
            self.fail(msg='Uncaught exception during test:\n' + traceback.format_exc())

        # The implementation should know whether things are shutting
        # down cleanly. We just make sure we clean up aggressively if
        # necessary.
        if not procs.done():
            procs.wait(until=self.duration, killAt=self.duration, output=output)

        # Print a notification if we had to kill this process
        if procs.killed():
            self.fail('Timed out')

        service_output.close()
        self.report_files = {self.service_name: service_output_filename}

        self.assertLogErrorFree(service_output_filename)
        self.assertReturnCode(procs.returncode())
Beispiel #3
0
    def runTest(self):
        dbFilename = os.path.join(self._folder, 'unit_test_csv_db.db')
        cppoh_output_filename = os.path.join(self._folder, 'cppoh.log')
        space_output_filename = os.path.join(self._folder, 'space.log')

        procs = ProcSet()

        # Random port to avoid conflicts
        port = random.randint(2000, 3000)
        # Space
        space_cmd = [ self._binaries['space'] ]
        space_cmd.append('--servermap-options=--port=' + str(port))

        space_output = open(space_output_filename, 'w')
        print(' '.join(space_cmd), file=space_output)
        space_output.flush()
        procs.process('space', space_cmd, stdout=space_output, stderr=subprocess.STDOUT, wait=False)
        # Wait for space to startup
        procs.sleep(3)


        # OH - create the db file to read from.
        csvGen = CSVGenerator(self.entities);
        csvGen.write(dbFilename)
        cppoh_cmd = [ self._binaries['cppoh'] ]
        cppoh_cmd.append('--servermap-options=--port=' + str(port))
        cppoh_cmd.append('--object-factory=csv')
        cppoh_cmd.append('--object-factory-opts=--db='+ os.path.abspath(dbFilename))
        if self.script_paths:
            cppoh_cmd.append('--objecthost=--scriptManagers=js:{--import-paths=%s}' % (','.join(self.script_paths)))

        cppoh_output = open(cppoh_output_filename,'w')
        print(' '.join(cppoh_cmd), file=cppoh_output)
        cppoh_output.flush()
        procs.process('cppoh', cppoh_cmd, stdout=cppoh_output, stderr=subprocess.STDOUT, default=True)

        # This type of test expects things to exit cleanly
        procs.wait(until=self.duration, killAt=self.duration+10, output=self.output)

        # Print a notification if we had to kill this process
        if (self.needs_hup and procs.killed()) or (not self.needs_hup and procs.hupped()):
            self.fail('Timed out')

        space_output.close()
        cppoh_output.close()
        self.report_files = { 'Object Host': cppoh_output_filename, 'Space Server': space_output_filename}

        self.assertLogErrorFree(cppoh_output_filename)
        self.assertReturnCode(procs.returncode())
Beispiel #4
0
    def runTest(self):
        try:
            if hasattr(self, 'testPre') and callable(self.testPre):
                self.testPre()
        except:
            self.fail(msg='Uncaught exception during pre test:\n' +
                      traceback.format_exc())

        procs = ProcSet()
        self.report_files = {}
        self._outputs = {}
        for svc_idx, svc in enumerate(self.services):
            svc_name = svc['name']

            service_output_filename = os.path.join(self._folder,
                                                   svc_name + '.log')

            # Add with http port
            self.add_http(svc_name)
            service_cmd = [self._binaries[svc['type']]]
            service_cmd += self.http_settings(svc_name)
            if svc['type'] == 'cppoh':
                service_cmd.append(
                    '--objecthost=--scriptManagers=js:{--import-paths=%s}' %
                    (','.join(self.script_paths)))
            if 'args' in svc:
                args = svc['args']
                if callable(args): args = args(self)
                service_cmd += [
                    '--' + k + '=' + v for k, v in args.iteritems()
                ]

            service_output = open(service_output_filename, 'w')
            print(service_cmd, file=service_output)
            service_output.flush()
            default_proc = (('default' in svc) and svc['default']) or False
            wait_proc = ('wait' not in svc) or svc['wait']
            procs.process(svc_name,
                          service_cmd,
                          stdout=service_output,
                          stderr=subprocess.STDOUT,
                          default=default_proc,
                          wait=wait_proc)

            self._outputs[svc_name] = service_output
            self.report_files[svc_name] = service_output_filename

            # If requested, block for upto 10 seconds for the process to start responding to commands
            if self.wait_until_responsive:
                result = self.command(svc_name,
                                      'meta.commands',
                                      retries=40,
                                      wait=.25)
                if result is None:
                    self.fail(
                        'Server never became responsive to HTTP commands: ' +
                        svc_name)

        # Defer to the implementation for sending and checking test
        # commands. Catch all errors so we can make sure we cleanup the
        # processes properly and report crashes, etc.
        try:
            self.testBody()
        except:
            self.fail(msg='Uncaught exception during test:\n' +
                      traceback.format_exc())

        # The implementation should know whether things are shutting
        # down cleanly. We just make sure we clean up aggressively if
        # necessary.
        if not procs.done():
            procs.wait(until=self.duration,
                       killAt=self.duration,
                       output=self.output)

        # Print a notification if we had to kill this process
        if procs.killed():
            self.fail('Timed out')

        for output in self._outputs.values():
            output.close()
        for output_filename in self.report_files.values():
            self.assertLogErrorFree(service_output_filename)

        self.assertReturnCode(procs.returncode())
        self.procs = procs

        try:
            if hasattr(self, 'testPost') and callable(self.testPost):
                self.testPost()
        except:
            self.fail(msg='Uncaught exception during post test:\n' +
                      traceback.format_exc())
Beispiel #5
0
    def runTest(self, outputPath, binPath, cppohBinName, spaceBinName, output=sys.stdout):
        bins = {
            'space' : os.path.join(binPath, spaceBinName),
            'cppoh' : os.path.join(binPath, cppohBinName)
            }

        procs = ProcSet()
        self.report_files = {}
        self._outputs = {}
        for svc_idx,svc in enumerate(self.services):
            svc_name = svc['name']

            service_output_filename = os.path.join(outputPath, svc_name + '.log')

            # Add with http port
            self.add_http(svc_name)
            service_cmd = [bins[svc['type']]]
            service_cmd += self.http_settings(svc_name)
            if svc['type'] == 'cppoh':
                service_cmd.append('--objecthost=--scriptManagers=js:{--import-paths=%s}' % (','.join(self.script_paths)))
            if 'args' in svc:
                args = svc['args']
                if callable(args): args = args(self)
                service_cmd += ['--' + k + '=' + v for k,v in args.iteritems()]

            service_output = open(service_output_filename, 'w')
            print(' '.join(service_cmd), file=service_output)
            service_output.flush()
            default_proc = (('default' in svc) and svc['default']) or False
            wait_proc = ('wait' not in svc) or svc['wait']
            procs.process(service_cmd, stdout=service_output, stderr=subprocess.STDOUT, default=default_proc, wait=wait_proc)

            self._outputs[svc_name] = service_output
            self.report_files[svc_name] = service_output_filename

            # If requested, block for upto 10 seconds for the process to start responding to commands
            if self.wait_until_responsive:
                result = self.command(svc_name, 'meta.commands', retries=40, wait=.25, output=output)
                if result is None: self.fail('Server never became responsive to HTTP commands')

        # Defer to the implementation for sending and checking test
        # commands. Catch all errors so we can make sure we cleanup the
        # processes properly and report crashes, etc.
        try:
            self.testBody(procs, output=output)
        except:
            self.fail(msg='Uncaught exception during test:\n' + traceback.format_exc())

        # The implementation should know whether things are shutting
        # down cleanly. We just make sure we clean up aggressively if
        # necessary.
        if not procs.done():
            procs.wait(until=self.duration, killAt=self.duration, output=output)

        # Print a notification if we had to kill this process
        if procs.killed():
            self.fail('Timed out')

        for output in self._outputs.values():
            output.close()
        for output_filename in self.report_files.values():
            self.assertLogErrorFree(service_output_filename)

        self.assertReturnCode(procs.returncode())
Beispiel #6
0
    def runTest(self):
        dbFilename = os.path.join(self._folder, 'unit_test_csv_db.db')
        cppoh_output_filename = os.path.join(self._folder, 'cppoh.log')
        space_output_filename = os.path.join(self._folder, 'space.log')

        procs = ProcSet()

        # Random port to avoid conflicts
        port = random.randint(2000, 3000)
        # Space
        space_cmd = [self._binaries['space']]
        space_cmd.append('--servermap-options=--port=' + str(port))

        space_output = open(space_output_filename, 'w')
        print(' '.join(space_cmd), file=space_output)
        space_output.flush()
        procs.process('space',
                      space_cmd,
                      stdout=space_output,
                      stderr=subprocess.STDOUT,
                      wait=False)
        # Wait for space to startup
        procs.sleep(3)

        # OH - create the db file to read from.
        csvGen = CSVGenerator(self.entities)
        csvGen.write(dbFilename)
        cppoh_cmd = [self._binaries['cppoh']]
        cppoh_cmd.append('--servermap-options=--port=' + str(port))
        cppoh_cmd.append('--object-factory=csv')
        cppoh_cmd.append('--object-factory-opts=--db=' +
                         os.path.abspath(dbFilename))
        if self.script_paths:
            cppoh_cmd.append(
                '--objecthost=--scriptManagers=js:{--import-paths=%s}' %
                (','.join(self.script_paths)))

        cppoh_output = open(cppoh_output_filename, 'w')
        print(' '.join(cppoh_cmd), file=cppoh_output)
        cppoh_output.flush()
        procs.process('cppoh',
                      cppoh_cmd,
                      stdout=cppoh_output,
                      stderr=subprocess.STDOUT,
                      default=True)

        # This type of test expects things to exit cleanly
        procs.wait(until=self.duration,
                   killAt=self.duration + 10,
                   output=self.output)

        # Print a notification if we had to kill this process
        if (self.needs_hup and procs.killed()) or (not self.needs_hup
                                                   and procs.hupped()):
            self.fail('Timed out')

        space_output.close()
        cppoh_output.close()
        self.report_files = {
            'Object Host': cppoh_output_filename,
            'Space Server': space_output_filename
        }

        self.assertLogErrorFree(cppoh_output_filename)
        self.assertReturnCode(procs.returncode())