Пример #1
0
  def testTailWithIndexInBounds(self):
    # calling 'appscale tail 1 *' should tail from the second node
    # (nodes[1]). If there are two nodes in this deployment,
    # we should tail from it successfully
    appscale = AppScale()

    contents = { 'keyname' : 'boo' }
    yaml_dumped_contents = yaml.dump(contents)

    one = {
      'public_ip' : 'blarg'
    }
    two = {
      'public_ip' : 'blarg2'
    }
    nodes = [one, two]
    nodes_contents = json.dumps(nodes)

    mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
    (mock.should_receive('open')
      .with_args(appscale.get_locations_json_file('boo'))
      .and_return(flexmock(read=lambda: nodes_contents)))

    flexmock(subprocess)
    subprocess.should_receive('call').with_args(["ssh", "-o",
      "StrictHostkeyChecking=no", "-i", appscale.get_key_location('boo'),
      "root@blarg2", "tail -f /var/log/appscale/c*"]).and_return().once()
    appscale.tail(1, "c*")
Пример #2
0
  def testTailWithIndexInBounds(self):
    # calling 'appscale tail 1 *' should tail from the second node
    # (nodes[1]). If there are two nodes in this deployment,
    # we should tail from it successfully
    appscale = AppScale()

    contents = { 'keyname' : 'boo' }
    yaml_dumped_contents = yaml.dump(contents)

    one = {
      'public_ip' : 'blarg'
    }
    two = {
      'public_ip' : 'blarg2'
    }
    nodes = [one, two]
    nodes_contents = json.dumps(nodes)

    mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
    (mock.should_receive('open')
      .with_args(appscale.get_locations_json_file('boo'))
      .and_return(flexmock(read=lambda: nodes_contents)))

    flexmock(subprocess)
    subprocess.should_receive('call').with_args(["ssh", "-o",
      "StrictHostkeyChecking=no", "-i", appscale.get_key_location('boo'),
      "root@blarg2", "tail -F /var/log/appscale/c*"]).and_return().once()
    appscale.tail(1, "c*")
Пример #3
0
    def testTailWithNoNodesJson(self):
        # calling 'appscale tail' when there isn't a locations.json
        # file should throw up and die
        appscale = AppScale()

        contents = {'keyname': 'boo'}
        yaml_dumped_contents = yaml.dump(contents)

        mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
        (mock.should_receive('open').with_args(
            appscale.get_locations_json_file('boo')).and_raise(IOError))

        self.assertRaises(AppScaleException, appscale.tail, 0, "")
Пример #4
0
  def testTailWithNoNodesJson(self):
    # calling 'appscale tail' when there isn't a locations.json
    # file should throw up and die
    appscale = AppScale()

    contents = { 'keyname' : 'boo' }
    yaml_dumped_contents = yaml.dump(contents)

    mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
    (mock.should_receive('open')
      .with_args(appscale.get_locations_json_file('boo'))
      .and_raise(IOError))

    self.assertRaises(AppScaleException, appscale.tail, 0, "")
Пример #5
0
    def testTailWithIndexOutOfBounds(self):
        # calling 'appscale tail 1 *' should tail from the second node
        # (nodes[1]). If there's only one node in this deployment,
        # we should throw up and die
        appscale = AppScale()

        contents = {'keyname': 'boo'}
        yaml_dumped_contents = yaml.dump(contents)

        one = {'public_ip': 'blarg'}
        nodes = [one]
        nodes_contents = json.dumps(nodes)

        mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
        (mock.should_receive('open').with_args(
            appscale.get_locations_json_file('boo')).and_return(
                flexmock(read=lambda: nodes_contents)))

        self.assertRaises(AppScaleException, appscale.tail, 1, '')
Пример #6
0
  def testTailWithIndexOutOfBounds(self):
    # calling 'appscale tail 1 *' should tail from the second node
    # (nodes[1]). If there's only one node in this deployment,
    # we should throw up and die
    appscale = AppScale()

    contents = { 'keyname' : 'boo' }
    yaml_dumped_contents = yaml.dump(contents)

    one = {
      'public_ip' : 'blarg'
    }
    nodes = [one]
    nodes_contents = json.dumps(nodes)

    mock = self.addMockForAppScalefile(appscale, yaml_dumped_contents)
    (mock.should_receive('open')
      .with_args(appscale.get_locations_json_file('boo'))
      .and_return(flexmock(read=lambda: nodes_contents)))

    self.assertRaises(AppScaleException, appscale.tail, 1, '')