<s> import os <EOL> import shutil <EOL> import datetime <EOL> import subprocess <EOL> from freezer . tests . freezer_tempest_plugin . tests . api import base <EOL> from tempest import test <EOL> class TestFreezerFSBackup ( base . BaseFreezerTest ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TestFreezerFSBackup , self ) . __init__ ( * args , ** kwargs ) <EOL> def setUp ( self ) : <EOL> super ( TestFreezerFSBackup , self ) . setUp ( ) <EOL> now_in_secs = datetime . datetime . now ( ) . strftime ( "<STR_LIT:%s>" ) <EOL> self . backup_source_dir = ( "<STR_LIT>" <EOL> + now_in_secs ) <EOL> self . backup_source_sub_dir = self . backup_source_dir + "<STR_LIT>" <EOL> self . restore_target_dir = ( <EOL> "<STR_LIT>" <EOL> + now_in_secs ) <EOL> self . backup_local_storage_dir = ( <EOL> "<STR_LIT>" <EOL> + now_in_secs ) <EOL> self . freezer_backup_name = '<STR_LIT>' <EOL> shutil . rmtree ( self . backup_source_dir , True ) <EOL> os . makedirs ( self . backup_source_dir ) <EOL> open ( self . backup_source_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> open ( self . backup_source_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> open ( self . backup_source_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> os . makedirs ( self . backup_source_sub_dir ) <EOL> open ( self . backup_source_sub_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> open ( self . backup_source_sub_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> open ( self . backup_source_sub_dir + "<STR_LIT>" , '<STR_LIT:w>' ) . close ( ) <EOL> shutil . rmtree ( self . restore_target_dir , True ) <EOL> os . makedirs ( self . restore_target_dir ) <EOL> shutil . rmtree ( self . backup_local_storage_dir , True ) <EOL> os . makedirs ( self . backup_local_storage_dir ) <EOL> self . environ = super ( TestFreezerFSBackup , self ) . get_environ ( ) <EOL> def tearDown ( self ) : <EOL> super ( TestFreezerFSBackup , self ) . tearDown ( ) <EOL> shutil . rmtree ( self . backup_source_dir , True ) <EOL> shutil . rmtree ( self . restore_target_dir , True ) <EOL> shutil . rmtree ( self . backup_local_storage_dir ) <EOL> @ test . attr ( type = "<STR_LIT>" ) <EOL> def test_freezer_fs_backup ( self ) : <EOL> backup_args = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> self . backup_source_dir , <EOL> '<STR_LIT>' , <EOL> self . backup_local_storage_dir , <EOL> '<STR_LIT>' , <EOL> self . freezer_backup_name , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> output = subprocess . check_output ( backup_args , <EOL> stderr = subprocess . STDOUT , <EOL> env = self . environ , shell = False ) <EOL> restore_args = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> self . restore_target_dir , <EOL> '<STR_LIT>' , <EOL> self . backup_local_storage_dir , <EOL> '<STR_LIT>' , <EOL> self . freezer_backup_name , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> output = subprocess . check_output ( restore_args , <EOL> stderr = subprocess . STDOUT , <EOL> env = self . environ , shell = False ) <EOL> diff_args = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> self . backup_source_dir , <EOL> self . restore_target_dir ] <EOL> diff_rc = subprocess . call ( diff_args , <EOL> shell = False ) <EOL> self . assertEqual ( <NUM_LIT:0> , diff_rc , "<STR_LIT>" <EOL> "<STR_LIT>" ) </s>
