def setup(self): """Builds and runs docker image with specified test config.""" # Download gcloud auth token. utils.download_from_gcs('gs://tf-performance/auth_tokens/*', self.auth_token_dir) # Set up the raid array. if self.gce_nvme_raid == 'all': devices = device_utils.get_nvme_devices() device_utils.create_drive_from_devices(self.data_dir, devices) # Check out git repos git_repos = self._get_git_repos() for git_repo in git_repos: utils.checkout_git_repo(git_repo.get('url'), os.path.join(self.site_packages_dir, git_repo.get('local_path')), branch=git_repo.get('branch'), sha_hash=git_repo.get('sha_hash')) # Download data gcs_downloads = self._get_gcs_downloads() for gcs_download in gcs_downloads: local_path = os.path.join(self.data_dir, gcs_download['local_path']) utils.download_from_gcs(gcs_download['gcs_path'], local_path) # Build docker image. docker_build_cmd = 'docker build --pull -f {} -t {} .'.format( self.docker_file_path, self.docker_tag) utils.run_commands([docker_build_cmd])
def create_single_drive(data_dir, device): """Creates a data drive out of a single device.""" cmds = [] cmds.append('sudo mkfs.ext4 -F {}'.format(device)) cmds.append('sudo mkdir -p {}'.format(data_dir)) cmds.append('sudo mount {} {}'.format(device, data_dir)) cmds.append('sudo chmod a+w {}'.format(data_dir)) utils.run_commands(cmds) print('Created and mounted device {} at {}'.format(device, data_dir))
def create_ram_disk(data_dir, disk_size): """Create a RAM disk.""" cmd = 'sudo mountpoint -q {}'.format(data_dir) retcode, _ = utils.run_command(cmd) if retcode: cmds = [] cmds.append('sudo mkdir -p {}'.format(data_dir)) cmds.append('sudo mount -t tmpfs -o size={}m tmpfs {}'.format( disk_size, data_dir)) utils.run_commands(cmds) else: print('RAM disk or something else is mounted at {}'.format(data_dir))
def create_drive_raid(data_dir, list_of_devices): """Creates a raid zero array of nvme drives.""" cmds = [] # Passing 'yes' because GCE nvme drive are sometimes in an odd state and # think they are in another raid. mdadm does not have -y option. # Or the kokoro images were left dirty? and that is where the info # comes from. cmds.append('yes | sudo mdadm --create /dev/md0 --level=0 ' '--raid-devices={} {}'.format(len(list_of_devices), ' '.join(list_of_devices))) cmds.append('sudo mkfs.ext4 -F /dev/md0') cmds.append('sudo mkdir -p {}'.format(data_dir)) cmds.append('sudo mount /dev/md0 {}'.format(data_dir)) cmds.append('sudo chmod a+w {}'.format(data_dir)) utils.run_commands(cmds) print('Created and mounted RAID array at {}'.format(data_dir))
def create_gce_nvme_raid(data_dir, list_of_devices): """Creates a raid zero array of nvme drives.""" cmd = 'sudo mountpoint -q {}'.format(data_dir) retcode, _ = utils.run_command(cmd) if retcode: cmds = [] # GCE nvme drives some times are in an odd state and # think they are in another raid. mdadm doe snot have -y option. # or the kokoro images were left dirty? and that is where the info # comes from. cmds.append('yes | sudo mdadm --create /dev/md0 --level=0 ' '--raid-devices={} {}'.format( len(list_of_devices), ' '.join(list_of_devices))) cmds.append('sudo mkfs.ext4 -F /dev/md0') cmds.append('sudo mkdir -p {}'.format(data_dir)) cmds.append('sudo mount /dev/md0 {}'.format(data_dir)) cmds.append('sudo chmod a+w {}'.format(data_dir)) utils.run_commands(cmds) print('Created and mounted RAID array at {}'.format(data_dir)) else: print('Skipping RAID array creation since path {} already exists'.format( data_dir))