Exemplo n.º 1
0
 def testErrorResponse(self):
   self.response = {'status': 400}
   with self.assertRaises(gitiles.GitilesError):
     gitiles.call_gitiles(
         'http://bananas',
         'text',
         os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 2
0
 def testInvalidResponse(self):
   self.response = {'status': '500'}
   with self.assertRaises(gitiles.GitilesError):
     gitiles.call_gitiles(
         'http://bananas',
         'text',
         os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 3
0
    def testInvalidJsonResponse(self):
        self.content = 'blerg\ndefinitely does not start with )]}\''
        with self.assertRaises(gitiles.GitilesError):
            gitiles.call_gitiles('http://bananas', 'json',
                                 os.path.join(DATA_DIR, 'netrc'))

        self.content = 'definitely does not have a newline'
        with self.assertRaises(gitiles.GitilesError):
            gitiles.call_gitiles('http://bananas', 'json',
                                 os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 4
0
  def testInvalidJsonResponse(self):
    self.content = 'blerg\ndefinitely does not start with )]}\''
    with self.assertRaises(gitiles.GitilesError):
      gitiles.call_gitiles(
          'http://bananas',
          'json',
          os.path.join(DATA_DIR, 'netrc'))

    self.content = 'definitely does not have a newline'
    with self.assertRaises(gitiles.GitilesError):
      gitiles.call_gitiles(
          'http://bananas',
          'json',
          os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 5
0
def main():
    args = parse_args()

    if args.json_file:
        desired_state = desired_state_parser.load_desired_state_file(
            args.json_file)
    else:
        desired_state_data = gitiles.call_gitiles(args.json_gitiles,
                                                  'text',
                                                  netrc_path=args.netrc)
        desired_state = desired_state_parser.parse_desired_state(
            desired_state_data)

    if args.verify:
        return 0  # File checks out, no need to continue.

    triggered, ignored = desired_state_parser.get_masters_for_host(
        desired_state, args.build_dir, args.hostname)
    log_triggered_ignored(triggered, ignored, args.hostname)

    commands = [
        synthesize_master_manager_cmd(m, args.hostname, prod=args.prod)
        for m in triggered
    ]

    if args.command_timeout:
        commands = [
            daemon.add_timeout(c, args.command_timeout) for c in commands
        ]

    multiprocess.safe_map(subprocess.call, commands, args.processes)
Exemplo n.º 6
0
def main():
  args = parse_args()
  # Flushing metrics here to be sure the presence/up got sent even if the
  # program runs for less than a minute.
  ts_mon.flush()

  if args.json_file:
    desired_state = desired_state_parser.load_desired_state_file(
        args.json_file)
  else:
    desired_state_data = gitiles.call_gitiles(
        args.json_gitiles, 'text', netrc_path=args.netrc)
    desired_state = desired_state_parser.parse_desired_state(desired_state_data)

  if args.verify:
    return 0  # File checks out, no need to continue.

  triggered, ignored = desired_state_parser.get_masters_for_host(
      desired_state, args.build_dir, args.hostname)
  log_triggered_ignored(triggered, ignored, args.hostname)

  commands = [
      synthesize_master_manager_cmd(m, args.hostname, prod=args.prod)
      for m in triggered
  ]

  if args.command_timeout:
    commands = [daemon.add_timeout(c, args.command_timeout) for c in commands]

  multiprocess.safe_map(subprocess.call, commands, args.processes)
Exemplo n.º 7
0
 def testNoAuth(self):
   with open(os.path.join(DATA_DIR, 'scripts_slave')) as f:
     self.content = f.read()
   result = gitiles.call_gitiles(
       'http://twirly',
       'json'
   )
   self.assertEqual(result['id'], '24a7f79e278700fab6dfd3866b1b8508c44ddb55')
Exemplo n.º 8
0
    def testText(self):
        with open(os.path.join(DATA_DIR, 'init_py')) as f:
            self.content = f.read()

        result = gitiles.call_gitiles('http://bananas', 'text',
                                      os.path.join(DATA_DIR, 'netrc'))

        self.assertTrue(result.startswith('# Copyright 2015'))
Exemplo n.º 9
0
 def testNoAuth(self):
   with open(os.path.join(DATA_DIR, 'scripts_slave')) as f:
     self.content = f.read()
   result = gitiles.call_gitiles(
       'http://twirly',
       'json'
   )
   self.assertEqual(result['id'], '24a7f79e278700fab6dfd3866b1b8508c44ddb55')
Exemplo n.º 10
0
  def testText(self):
    with open(os.path.join(DATA_DIR, 'init_py')) as f:
      self.content = f.read()

    result = gitiles.call_gitiles(
        'http://bananas',
        'text',
        os.path.join(DATA_DIR, 'netrc'))

    self.assertTrue(result.startswith('# Copyright 2015'))
Exemplo n.º 11
0
 def testBadAuth(self):
   with self.assertRaises(gitiles.GitilesError):
     gitiles.call_gitiles(
         'http://twirly',
         'json',
         os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 12
0
 def testQueryInUrl(self):
   with self.assertRaises(AssertionError):
     gitiles.call_gitiles(
         'http://bananas?foster',
         'text',
         os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 13
0
 def testBadAuth(self):
   with self.assertRaises(gitiles.GitilesError):
     gitiles.call_gitiles(
         'http://twirly',
         'json',
         os.path.join(DATA_DIR, 'netrc'))
Exemplo n.º 14
0
 def testQueryInUrl(self):
   with self.assertRaises(AssertionError):
     gitiles.call_gitiles(
         'http://bananas?foster',
         'text',
         os.path.join(DATA_DIR, 'netrc'))