1*9c5db199SXin Li# Copyright 2015 The Chromium Authors. All rights reserved. 2*9c5db199SXin Li# Use of this source code is governed by a BSD-style license that can be 3*9c5db199SXin Li# found in the LICENSE file. 4*9c5db199SXin Li 5*9c5db199SXin Liimport os 6*9c5db199SXin Li 7*9c5db199SXin Liimport common 8*9c5db199SXin Lifrom autotest_lib.client.bin import utils as common_utils 9*9c5db199SXin Lifrom autotest_lib.client.common_lib.global_config import global_config 10*9c5db199SXin Li 11*9c5db199SXin Li 12*9c5db199SXin Li# Name of the base container. 13*9c5db199SXin LiBASE = global_config.get_config_value('AUTOSERV', 'container_base_name') 14*9c5db199SXin Li 15*9c5db199SXin Li# Path to folder that contains autotest code inside container. 16*9c5db199SXin LiCONTAINER_AUTOTEST_DIR = '/usr/local/autotest' 17*9c5db199SXin Li 18*9c5db199SXin Li# Naming convention of the result directory in test container. 19*9c5db199SXin LiRESULT_DIR_FMT = os.path.join(CONTAINER_AUTOTEST_DIR, 'results', 20*9c5db199SXin Li '%s') 21*9c5db199SXin Li# Attributes to retrieve about containers. 22*9c5db199SXin LiATTRIBUTES = ['name', 'state'] 23*9c5db199SXin Li 24*9c5db199SXin Li# url to the folder stores base container. 25*9c5db199SXin LiCONTAINER_BASE_FOLDER_URL = global_config.get_config_value('AUTOSERV', 26*9c5db199SXin Li 'container_base_folder_url') 27*9c5db199SXin LiCONTAINER_BASE_URL_FMT = '%s/%%s.tar.xz' % CONTAINER_BASE_FOLDER_URL 28*9c5db199SXin LiCONTAINER_BASE_URL = CONTAINER_BASE_URL_FMT % BASE 29*9c5db199SXin Li# Default directory used to store LXC containers. 30*9c5db199SXin LiDEFAULT_CONTAINER_PATH = global_config.get_config_value('AUTOSERV', 31*9c5db199SXin Li 'container_path') 32*9c5db199SXin Li# Default directory used to store the base LXC container. 33*9c5db199SXin LiDEFAULT_BASE_CONTAINER_PATH = global_config.get_config_value( 34*9c5db199SXin Li 'AUTOSERV', 'base_container_path') 35*9c5db199SXin Li# Default directory for host mounts 36*9c5db199SXin LiDEFAULT_SHARED_HOST_PATH = global_config.get_config_value( 37*9c5db199SXin Li 'AUTOSERV', 38*9c5db199SXin Li 'container_shared_host_path') 39*9c5db199SXin Li 40*9c5db199SXin Li# The name of the linux domain socket used by the container pool. Just one 41*9c5db199SXin Li# exists, so this is just a hard-coded string. 42*9c5db199SXin LiDEFAULT_CONTAINER_POOL_SOCKET = 'container_pool_socket' 43*9c5db199SXin Li 44*9c5db199SXin Li# Default size for the lxc container pool. 45*9c5db199SXin LiDEFAULT_CONTAINER_POOL_SIZE = 20 46*9c5db199SXin Li 47*9c5db199SXin Li# Location of the host mount point in the container. 48*9c5db199SXin LiCONTAINER_HOST_DIR = '/host' 49*9c5db199SXin Li 50*9c5db199SXin Li# Path to drone_temp folder in the container, which stores the control file for 51*9c5db199SXin Li# test job to run. 52*9c5db199SXin LiCONTROL_TEMP_PATH = os.path.join(CONTAINER_AUTOTEST_DIR, 'drone_tmp') 53*9c5db199SXin Li 54*9c5db199SXin Li# Bash command to return the file count in a directory. Test the existence first 55*9c5db199SXin Li# so the command can return an error code if the directory doesn't exist. 56*9c5db199SXin LiCOUNT_FILE_CMD = '[ -d %(dir)s ] && ls %(dir)s | wc -l' 57*9c5db199SXin Li 58*9c5db199SXin Li# Seconds to wait for successful completion of a lxc force-destroy 59*9c5db199SXin LiLXC_SCRUB_TIMEOUT = 300 60*9c5db199SXin Li 61*9c5db199SXin Li# Command line to append content to a file 62*9c5db199SXin LiAPPEND_CMD_FMT = ('echo \'%(content)s\' | sudo tee --append %(file)s' 63*9c5db199SXin Li '> /dev/null') 64*9c5db199SXin Li 65*9c5db199SXin Li# Flag to indicate it's running in a Moblab. Due to crbug.com/457496, lxc-ls has 66*9c5db199SXin Li# different behavior in Moblab. 67*9c5db199SXin LiIS_MOBLAB = common_utils.is_moblab() 68*9c5db199SXin Li 69*9c5db199SXin Liif IS_MOBLAB: 70*9c5db199SXin Li SITE_PACKAGES_PATH = '/usr/lib64/python2.7/site-packages' 71*9c5db199SXin Li CONTAINER_SITE_PACKAGES_PATH = '/usr/local/lib/python2.7/dist-packages/' 72*9c5db199SXin Lielse: 73*9c5db199SXin Li SITE_PACKAGES_PATH = os.path.join(common.autotest_dir, 'site-packages') 74*9c5db199SXin Li CONTAINER_SITE_PACKAGES_PATH = os.path.join(CONTAINER_AUTOTEST_DIR, 75*9c5db199SXin Li 'site-packages') 76*9c5db199SXin Li 77*9c5db199SXin Li# This is an alternate site_packages that is built to be Trusty 78*9c5db199SXin Li# compatible. crbug.com/1013241 79*9c5db199SXin LiTRUSTY_SITE_PACKAGES_PATH = '/opt/trusty_site_packages' 80*9c5db199SXin Li 81*9c5db199SXin Li# TODO(dshi): If we are adding more logic in how lxc should interact with 82*9c5db199SXin Li# different systems, we should consider code refactoring to use a setting-style 83*9c5db199SXin Li# object to store following flags mapping to different systems. 84*9c5db199SXin LiSUPPORT_SNAPSHOT_CLONE = True 85*9c5db199SXin Li 86*9c5db199SXin Li# Number of seconds to wait for network to be up in a container. 87*9c5db199SXin LiNETWORK_INIT_TIMEOUT = 1200 88*9c5db199SXin Li# Network bring up is slower in Moblab. 89*9c5db199SXin Li# TODO(184304822) reset back to 0.1 for the main lab. 90*9c5db199SXin LiNETWORK_INIT_CHECK_INTERVAL = 1 if IS_MOBLAB else 5 91*9c5db199SXin Li 92*9c5db199SXin Li# Number of seconds to download files from devserver. We chose a timeout that 93*9c5db199SXin Li# is on the same order as the permitted CTS runtime for normal jobs (1h). In 94*9c5db199SXin Li# principle we should not retry timeouts as they indicate server/network 95*9c5db199SXin Li# overload, but we may be tempted to retry for other failures. 96*9c5db199SXin LiDEVSERVER_CALL_TIMEOUT = 3600 97*9c5db199SXin Li# Number of retries to download files from devserver. There is no point in 98*9c5db199SXin Li# having more than one retry for a file download. 99*9c5db199SXin LiDEVSERVER_CALL_RETRY = 2 100*9c5db199SXin Li# Average delay before attempting a retry to download from devserver. This 101*9c5db199SXin Li# value needs to be large enough to allow an overloaded server/network to 102*9c5db199SXin Li# calm down even in the face of retries. 103*9c5db199SXin LiDEVSERVER_CALL_DELAY = 600 104*9c5db199SXin Li 105*9c5db199SXin Li# Type string for container related metadata. 106*9c5db199SXin LiCONTAINER_CREATE_METADB_TYPE = 'container_create' 107*9c5db199SXin LiCONTAINER_CREATE_RETRY_METADB_TYPE = 'container_create_retry' 108*9c5db199SXin LiCONTAINER_RUN_TEST_METADB_TYPE = 'container_run_test' 109*9c5db199SXin Li 110*9c5db199SXin Li# The container's hostname MUST start with `test-` or `test_`. DHCP server in 111*9c5db199SXin Li# MobLab uses that prefix to determine the lease time. Note that `test_` is not 112*9c5db199SXin Li# a valid hostname as hostnames cannot contain underscores. Work is underway to 113*9c5db199SXin Li# migrate to `test-`. See crbug/726131. 114*9c5db199SXin LiCONTAINER_UTSNAME_FORMAT = 'test-%s' 115*9c5db199SXin Li 116*9c5db199SXin LiSTATS_KEY = 'chromeos/autotest/lxc' 117*9c5db199SXin Li 118*9c5db199SXin LiCONTAINER_POOL_METRICS_PREFIX = 'chromeos/autotest/container_pool' 119