• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Lint as: python2, python3
2# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import time
7from autotest_lib.server import autotest
8from autotest_lib.server import hosts
9from autotest_lib.server import test
10
11
12class hardware_StorageQualBase(test.test):
13    """Tests run at the beginning over the disk qual test.
14
15    This code runs simple tests to ensure the device meet basic critera.
16    """
17
18    version = 1
19
20    FIO_ARGV = {'constraints': [
21        '_seq_read_read_bw >= 50 * 1024',
22        '_seq_write_write_bw >= 15 * 1024',
23        '_16k_write_write_iops >= 10'],
24        'requirements': [
25            ('seq_write', []),
26            ('seq_read', []),
27            ('4k_write', []),
28            ('4k_read', []),
29            ('16k_write', []),
30            ('16k_read', [])],
31    }
32
33
34    CLIENT_FUNCTIONAL_TESTS = [
35        ('hardware_DiskSize', {'constraints': ['gb_main_disk_size >= 8']}),
36        ('hardware_SsdDetection', {
37            'constraints': ['mb_ssd_device_size >= 8000']}),
38        ('hardware_StorageFio', FIO_ARGV)
39    ]
40
41    CRYPTO_RUNTIME = 5 * 60  # seconds.
42
43    CRYPTO_TESTS = [
44        'surfing',
45        'boot',
46        'login',
47        'seq_write',
48        'seq_read',
49        '16k_write',
50        '16k_read',
51        '8k_write',
52        '8k_read',
53        '4k_write',
54        '4k_read',
55    ]
56
57
58    def run_once(self,
59                 client_ip,
60                 client_tag='',
61                 crypto_runtime=CRYPTO_RUNTIME,
62                 cq=False,
63                 nonroot=False,
64                 skip_crypto=False):
65        """
66        Runs simple tests to ensure the device meets basic criteria.
67
68        @param client_ip: ip address of the client machine
69        @param client_tag: client tag for keyval label
70        @param crypto_runtime: runtime for platform.CryptohomeFio tests
71        @param cq: part of a cq run
72        @param skip_crypto: skip running cryptohome tests
73
74        """
75
76        # in a cq run, do not execute the test, just output
77        # the order that the test would have run in
78        if cq:
79            self.write_test_keyval(
80                {'storage_qual_cq': ('%f hardware_StorageQualBase_%s'
81                    % (time.time(), client_tag))})
82            return
83
84        client = hosts.create_host(client_ip)
85        client_at = autotest.Autotest(client)
86
87        if nonroot:
88            client_at.run_test("hardware_StorageFioOther", disable_sysinfo=True,
89                               tag=client_tag, **self.FIO_ARGV)
90        else:
91            for test_name, argv in self.CLIENT_FUNCTIONAL_TESTS:
92                client_at.run_test(test_name, disable_sysinfo=True,
93                                   tag=client_tag, **argv)
94
95            if not skip_crypto:
96                # Test real life performance
97                for script in self.CRYPTO_TESTS:
98                    client_at.run_test('platform_CryptohomeFio',
99                                       disable_sysinfo=True,
100                                       from_internal_disk_only=True,
101                                       script=script,
102                                       tag='_'.join([client_tag, script]),
103                                       runtime=crypto_runtime,
104                                       disk_configs=['crypto', 'plain'])
105