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