def __init__(self, name):
     super(BenchmarkSettings, self).__init__(name, 'benchmark')
     self.AddField(
         TextField('test_name',
                   description='The name of the test to run. '
                   'Defaults to the name of the benchmark.'))
     self.AddField(
         TextField('test_args',
                   description='Arguments to be passed to the '
                   'test.'))
     self.AddField(
         IntegerField('iterations',
                      default=1,
                      description='Number of iterations to run the '
                      'test.'))
     self.AddField(
         TextField('suite',
                   default='',
                   description='The type of the benchmark.'))
     self.AddField(
         IntegerField('retries',
                      default=0,
                      description='Number of times to retry a '
                      'benchmark run.'))
     self.AddField(
         BooleanField('run_local',
                      description='Run benchmark harness on the DUT. '
                      'Currently only compatible with the suite: '
                      'telemetry_Crosperf.',
                      required=False,
                      default=True))
Esempio n. 2
0
  def test_set_field(self):
    self.assertEqual(self.settings.fields, {})
    self.settings.AddField(
        IntegerField(
            'iterations',
            default=1,
            required=False,
            description='Number of iterations to run the '
            'test.'))
    res = self.settings.fields['iterations']
    self.assertEqual(res.Get(), 1)

    self.settings.SetField('iterations', 10)
    res = self.settings.fields['iterations']
    self.assertEqual(res.Get(), 10)

    # Setting a field that's not there raises an exception.
    self.assertRaises(Exception, self.settings.SetField, 'remote',
                      'lumpy1.cros')

    self.settings.AddField(
        ListField(
            'remote',
            default=[],
            description="A comma-separated list of ip's of "
            'chromeos devices to run '
            'experiments on.'))
    self.assertEqual(type(self.settings.fields), dict)
    self.assertEqual(len(self.settings.fields), 2)
    res = self.settings.fields['remote']
    self.assertEqual(res.Get(), [])
    self.settings.SetField('remote', 'lumpy1.cros', append=True)
    self.settings.SetField('remote', 'lumpy2.cros', append=True)
    res = self.settings.fields['remote']
    self.assertEqual(res.Get(), ['lumpy1.cros', 'lumpy2.cros'])
Esempio n. 3
0
  def test_validate(self):

    self.settings.AddField(
        IntegerField(
            'iterations',
            required=True,
            description='Number of iterations '
            'to run the test.'))
    self.settings.AddField(
        ListField(
            'remote',
            default=[],
            required=True,
            description='A comma-separated list '
            "of ip's of chromeos "
            'devices to run experiments on.'))
    self.settings.AddField(
        ListField(
            'email',
            default=[],
            description='Space-seperated'
            'list of email addresses to '
            'send email to.'))

    # 'required' fields have not been assigned; should raise an exception.
    self.assertRaises(Exception, self.settings.Validate)
    self.settings.SetField('iterations', 2)
    self.settings.SetField('remote', 'x86-alex.cros', append=True)
    # Should run without exception now.
    self.settings.Validate()
Esempio n. 4
0
class User(Model):
    __table__ = 'users'
    uid = IntegerField(name='uid', primary_key=True)
    name = StringField(name='name', column_type='VARCHAR(16)')
    email = StringField(name='email',
                        column_type='VARCHAR(64)',
                        not_null=False)
Esempio n. 5
0
class XssforkTask(XssforkModel):
    id = IntegerField('id')
    time = StringField('time')
    url = StringField('url')
    cookie = StringField('cookie')
    data = StringField('data')
    destination = StringField('destination')
    status = 0
    __table__ = "xssfork_task"
    __show_sql__ = False
Esempio n. 6
0
 def test_add_field(self):
   self.assertEqual(self.settings.fields, {})
   self.settings.AddField(
       IntegerField(
           'iterations',
           default=1,
           required=False,
           description='Number of iterations to '
           'run the test.'))
   self.assertEqual(len(self.settings.fields), 1)
   # Adding the same field twice raises an exception.
   self.assertRaises(Exception, self.settings.AddField, (IntegerField(
       'iterations',
       default=1,
       required=False,
       description='Number of iterations to run '
       'the test.')))
   res = self.settings.fields['iterations']
   self.assertIsInstance(res, IntegerField)
   self.assertEqual(res.Get(), 1)
Esempio n. 7
0
class CreateOrderRequestModel:
    item = TextField(1)
    username = TextField(3)
    quantity = IntegerField(0, 100)

    @staticmethod
    def parse(data):
        if isinstance(data, (str, bytes)):
            data = loads(data)
        model = CreateOrderRequestModel()
        model.item = data.get('item', '')
        model.username = data.get('username', '')
        model.quantity = data.get('quantity', 0)
        return model
    def test_get_field(self):
        # Getting a field that's not there raises an exception.
        self.assertRaises(Exception, self.settings.GetField, 'iterations')

        # Getting a required field that hasn't been assigned raises an exception.
        self.settings.AddField(
            IntegerField('iterations',
                         required=True,
                         description='Number of iterations to '
                         'run the test.'))
        self.assertIsNotNone(self.settings.fields['iterations'])
        self.assertRaises(Exception, self.settings.GetField, 'iterations')

        # Set the value, then get it.
        self.settings.SetField('iterations', 5)
        res = self.settings.GetField('iterations')
        self.assertEqual(res, 5)
 def __init__(self, name):
   super(GlobalSettings, self).__init__(name, 'global')
   self.AddField(
       TextField(
           'name',
           description='The name of the experiment. Just an '
           'identifier.'))
   self.AddField(
       TextField(
           'board',
           description='The target board for running '
           'experiments on, e.g. x86-alex.'))
   self.AddField(
       ListField(
           'remote',
           description='A comma-separated list of IPs of '
           'chromeos devices to run experiments on.'))
   self.AddField(
       BooleanField(
           'rerun_if_failed',
           description='Whether to re-run failed test runs '
           'or not.',
           default=False))
   self.AddField(
       BooleanField(
           'rm_chroot_tmp',
           default=False,
           description='Whether to remove the test_that '
           'result in the chroot.'))
   self.AddField(
       ListField(
           'email',
           description='Space-separated list of email '
           'addresses to send email to.'))
   self.AddField(
       BooleanField(
           'rerun',
           description='Whether to ignore the cache and '
           'for tests to be re-run.',
           default=False))
   self.AddField(
       BooleanField(
           'same_specs',
           default=True,
           description='Ensure cached runs are run on the '
           'same kind of devices which are specified as a '
           'remote.'))
   self.AddField(
       BooleanField(
           'same_machine',
           default=False,
           description='Ensure cached runs are run on the '
           'same remote.'))
   self.AddField(
       BooleanField(
           'use_file_locks',
           default=False,
           description='Whether to use the file locks '
           'mechanism (deprecated) instead of the AFE '
           'server lock mechanism.'))
   self.AddField(
       IntegerField(
           'iterations',
           required=False,
           default=0,
           description='Number of iterations to run all tests. '
           'If not set, will run each benchmark test the optimum number of '
           'times to get a stable result.'))
   self.AddField(
       TextField(
           'chromeos_root',
           description='The path to a chromeos checkout which '
           'contains a src/scripts directory. Defaults to '
           'the chromeos checkout which contains the '
           'chromeos_image.'))
   self.AddField(
       TextField(
           'logging_level',
           default='average',
           description='The level of logging desired. '
           "Options are 'quiet', 'average', and 'verbose'."))
   self.AddField(
       IntegerField(
           'acquire_timeout',
           default=0,
           description='Number of seconds to wait for '
           'machine before exit if all the machines in '
           'the experiment file are busy. Default is 0.'))
   self.AddField(
       TextField(
           'perf_args',
           default='',
           description='The optional profile command. It '
           'enables perf commands to record perforamance '
           'related counters. It must start with perf '
           'command record or stat followed by arguments.'))
   self.AddField(
       TextField(
           'cache_dir',
           default='',
           description='The abs path of cache dir. '
           'Default is /home/$(whoami)/cros_scratch.'))
   self.AddField(
       BooleanField(
           'cache_only',
           default=False,
           description='Whether to use only cached '
           'results (do not rerun failed tests).'))
   self.AddField(
       BooleanField(
           'no_email',
           default=False,
           description='Whether to disable the email to '
           'user after crosperf finishes.'))
   self.AddField(
       BooleanField(
           'json_report',
           default=False,
           description='Whether to generate a json version '
           'of the report, for archiving.'))
   self.AddField(
       BooleanField(
           'show_all_results',
           default=False,
           description='When running Telemetry tests, '
           'whether to all the results, instead of just '
           'the default (summary) results.'))
   self.AddField(
       TextField(
           'share_cache',
           default='',
           description='Path to alternate cache whose data '
           'you want to use. It accepts multiple directories '
           'separated by a ",".'))
   self.AddField(
       TextField('results_dir', default='', description='The results dir.'))
   self.AddField(
       TextField(
           'locks_dir',
           default='',
           description='An alternate directory to use for '
           'storing/checking machine locks. Using this field '
           'automatically sets use_file_locks to True.\n'
           'WARNING: If you use your own locks directory, '
           'there is no guarantee that someone else might not '
           'hold a lock on the same machine in a different '
           'locks directory.'))
   self.AddField(
       TextField(
           'chrome_src',
           description='The path to the source of chrome. '
           'This is used to run telemetry benchmarks. '
           'The default one is the src inside chroot.',
           required=False,
           default=''))
   self.AddField(
       IntegerField(
           'retries',
           default=0,
           description='Number of times to retry a '
           'benchmark run.'))
Esempio n. 10
0
class Student(Model):
    id = IntegerField(is_primary_key=True)
    name = StringField()
    age = IntegerField()