示例#1
0
 def test_once_commands_blank(self):
     spec = {'commands': {'once': []}}
     port_spec = {'hosts_file': []}
     expected = [
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH), 'fi'
     ]
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)
示例#2
0
 def test_once_commands(self):
     spec = {'commands': {'once': ['once_script.sh']}}
     port_spec = {'hosts_file': []}
     expected = [
         'dusty_once_fn () {',
         'once_script.sh',
         '}',
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH),
     ] + command_file._tee_output_commands('dusty_once_fn') + ['fi']
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)
示例#3
0
 def test_once_commands_with_hosts(self):
     spec = {'commands': {'once': []}}
     port_spec = {'hosts_file': [{'host_address': 'local.something.com'}]}
     expected = [
         'dusty_once_fn () {',
         'DOCKERHOST=`ip route|awk \'/default/ { print $3 }\'`',
         'echo "$DOCKERHOST    local.something.com" >> /etc/hosts',
         '}',
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH),
     ] + command_file._tee_output_commands('dusty_once_fn') + ['fi']
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)
示例#4
0
 def test_once_commands_blank(self):
     spec = {
         'commands': {
             'once': []
         }
     }
     port_spec = {'hosts_file': []}
     expected = [
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH),
         'fi'
     ]
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)
示例#5
0
 def test_once_commands_with_hosts(self):
     spec = {
         'commands': {
             'once': []
         }
     }
     port_spec = {'hosts_file': [{'host_address': 'local.something.com'}]}
     expected = [
         'dusty_once_fn () {',
         'DOCKERHOST=`ip route|awk \'/default/ { print $3 }\'`',
         'echo "$DOCKERHOST    local.something.com" >> /etc/hosts',
         '}',
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH),
         ] + command_file._tee_output_commands('dusty_once_fn') + [
         'fi'
     ]
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)
示例#6
0
 def test_once_commands(self):
     spec = {
         'commands': {
             'once': [
                 'once_script.sh'
             ]
         }
     }
     port_spec = {'hosts_file': []}
     expected = [
         'dusty_once_fn () {',
         'once_script.sh',
         '}',
         'if [ ! -f {} ]; then'.format(constants.FIRST_RUN_FILE_PATH),
         'touch {}'.format(constants.FIRST_RUN_FILE_PATH),
         ] + command_file._tee_output_commands('dusty_once_fn') + [
         'fi'
     ]
     actual = command_file._get_once_commands(spec, port_spec)
     self.assertEqual(expected, actual)