Exemplo n.º 1
0
  def test_start_app_failed_copy_java(self):
    configuration = {
      'app_port': 2000,
      'login_server': 'public1',
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_details = {'runtime': 'java',
                       'revision': 1,
                       'deployment': {'zip': {'sourceUrl': 'source.tar.gz'}}}
    version_manager = flexmock(version_details=version_details)
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}
    app_manager_server.deployment_config = flexmock(
      get_config=lambda x: {'default_max_appserver_memory': 400})

    source_manager = flexmock()
    response = Future()
    response.set_result(None)
    source_manager.should_receive('ensure_source').\
      with_args('test_default_v1_1', 'source.tar.gz', 'java').\
      and_return(response)
    app_manager_server.source_manager = source_manager

    flexmock(app_manager_server).should_receive('find_web_inf').\
      and_return('/path/to/dir/WEB-INF')
    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_raise(IOError)

    with self.assertRaises(IOError):
      yield app_manager_server.start_app('test_default_v1', configuration)
  def test_start_app_goodconfig_java(self):
    configuration = {'app_name': 'test',
                     'app_port': 2000,
                     'language': 'java',
                     'load_balancer_ip': '127.0.0.1',
                     'load_balancer_port': 8080,
                     'xmpp_ip': '127.0.0.1',
                     'dblocations': ['127.0.0.1', '127.0.0.2'],
                     'env_vars': {},
                     'max_memory': 500}
    configuration = json.dumps(configuration)

    fake_secret = "XXXXXX"
    flexmock(appscale_info).should_receive('get_private_ip')\
      .and_return('<private_ip>')
    flexmock(appscale_info).should_receive('get_secret')\
                           .and_return(fake_secret)
    flexmock(monit_app_configuration).should_receive('create_config_file')\
                               .and_return('fakeconfig')
    flexmock(monit_interface).should_receive('start')\
                           .and_return(True)
    flexmock(app_manager_server).should_receive('wait_on_app')\
                         .and_return(True)
    flexmock(app_manager_server).should_receive('locate_dir')\
                        .and_return('/path/to/dir/')
    flexmock(os).should_receive('popen')\
                .and_return(flexmock(read=lambda: '0\n'))
    flexmock(file_io).should_receive('write')\
                        .and_return()
    flexmock(subprocess).should_receive('call')\
                        .and_return(0)
    self.assertEqual(0, app_manager_server.start_app(configuration))
Exemplo n.º 3
0
    def test_start_app_goodconfig_python(self):
        configuration = {
            'app_name': 'test',
            'app_port': 2000,
            'language': 'python',
            'load_balancer_ip': '127.0.0.1',
            'load_balancer_port': 8080,
            'xmpp_ip': '127.0.0.1',
            'dblocations': ['127.0.0.1', '127.0.0.2'],
            'env_vars': {}
        }
        configuration = json.dumps(configuration)

        fake_secret = "XXXXXX"
        flexmock(appscale_info).should_receive('get_private_ip')\
          .and_return('<private_ip>')
        flexmock(appscale_info).should_receive('get_secret')\
                               .and_return(fake_secret)
        flexmock(god_app_configuration).should_receive('create_config_file')\
                                   .and_return('fakeconfig')
        flexmock(god_interface).should_receive('start')\
                               .and_return(True)
        flexmock(app_manager_server).should_receive('wait_on_app')\
                             .and_return(True)
        flexmock(os).should_receive('popen')\
                    .and_return(flexmock(read=lambda: '12345\n'))
        flexmock(file_io).should_receive('write')\
                            .and_return()
        self.assertEqual(12345, app_manager_server.start_app(configuration))
Exemplo n.º 4
0
  def test_start_app_goodconfig_python(self):
    configuration = {
      'app_name': 'test',
      'app_port': 2000,
      'language': 'python27',
      'load_balancer_ip': '127.0.0.1',
      'load_balancer_port': 8080,
      'xmpp_ip': '127.0.0.1',
      'dblocations': ['127.0.0.1', '127.0.0.2'],
      'env_vars': {},
      'max_memory': 500
    }
    configuration = json.dumps(configuration)

    flexmock(appscale_info).should_receive('get_private_ip').\
      and_return('<private_ip>')
    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_return('fakeconfig')
    flexmock(monit_interface).should_receive('start').\
      and_return(True)
    flexmock(app_manager_server).should_receive('wait_on_app').\
      and_return(True)
    flexmock(os).should_receive('popen').\
      and_return(flexmock(read=lambda: '12345\n'))
    flexmock(file_io).should_receive('write').\
      and_return()
    flexmock(threading).should_receive('Thread').\
      and_return(flexmock(start=lambda: None))
    flexmock(app_manager_server).should_receive("setup_logrotate").and_return()
    self.assertEqual(0, app_manager_server.start_app(configuration))
  def test_start_app_goodconfig_python(self):
    configuration = {'app_name': 'test',
                     'app_port': 2000,
                     'language': 'python',
                     'load_balancer_ip': '127.0.0.1',
                     'load_balancer_port': 8080,
                     'xmpp_ip': '127.0.0.1',
                     'dblocations': ['127.0.0.1', '127.0.0.2'],
                     'env_vars': {}}
    configuration = json.dumps(configuration)

    fake_secret = "XXXXXX"
    flexmock(appscale_info).should_receive('get_private_ip')\
      .and_return('<private_ip>')
    flexmock(appscale_info).should_receive('get_secret')\
                           .and_return(fake_secret)
    flexmock(god_app_configuration).should_receive('create_config_file')\
                               .and_return('fakeconfig')
    flexmock(god_interface).should_receive('start')\
                           .and_return(True)
    flexmock(app_manager_server).should_receive('wait_on_app')\
                         .and_return(True)
    flexmock(os).should_receive('popen')\
                .and_return(flexmock(read=lambda: '12345\n'))
    flexmock(file_io).should_receive('write')\
                        .and_return()
    self.assertEqual(12345, app_manager_server.start_app(configuration))
Exemplo n.º 6
0
  def test_start_app_failed_copy_java(self):
    configuration = {
      'app_name': 'test',
      'app_port': 2000,
      'language': 'java',
      'load_balancer_ip': '127.0.0.1',
      'load_balancer_port': 8080,
      'xmpp_ip': '127.0.0.1',
      'dblocations': ['127.0.0.1', '127.0.0.2'],
      'max_memory': 500
    }
    configuration = json.dumps(configuration)

    flexmock(appscale_info).should_receive('get_private_ip').\
      and_return('<private_ip>')
    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_return('fakeconfig')
    flexmock(monit_interface).should_receive('start').and_return(True)
    flexmock(app_manager_server).should_receive('wait_on_app').\
      and_return(True)
    flexmock(os).should_receive('popen').\
      and_return(flexmock(read=lambda: '12345\n'))
    flexmock(file_io).should_receive('write').and_return()
    flexmock(subprocess).should_receive('call').and_return(1)
    self.assertEqual(-1, app_manager_server.start_app(configuration))
Exemplo n.º 7
0
  def test_start_app_failed_copy_java(self):
    configuration = {
      'app_port': 2000,
      'login_server': 'public1',
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_details = {'runtime': 'java',
                       'revision': 1,
                       'deployment': {'zip': {'sourceUrl': 'source.tar.gz'}}}
    version_manager = flexmock(version_details=version_details)
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}
    app_manager_server.deployment_config = flexmock(
      get_config=lambda x: {'default_max_appserver_memory': 400})

    source_manager = flexmock()
    response = Future()
    response.set_result(None)
    source_manager.should_receive('ensure_source').\
      with_args('test_default_v1_1', 'source.tar.gz', 'java').\
      and_return(response)
    app_manager_server.source_manager = source_manager

    flexmock(app_manager_server).should_receive('find_web_inf').\
      and_return('/path/to/dir/WEB-INF')
    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_raise(IOError)

    with self.assertRaises(IOError):
      yield app_manager_server.start_app('test_default_v1', configuration)
Exemplo n.º 8
0
 def test_start_app_bad_appname(self):
   configuration = {'app_name': 'badName!@#$%^&*([]/.,',
                    'app_port': 2000,
                    'language': 'python',
                    'load_balancer_ip': '127.0.0.1',
                    'load_balancer_port': 8080,
                    'xmpp_ip': '127.0.0.1',
                    'dblocations': ['127.0.0.1', '127.0.0.2']}
   configuration = json.dumps(configuration)
   self.assertEqual(-1, app_manager_server.start_app(configuration)) 
Exemplo n.º 9
0
    def test_start_app_goodconfig_python(self):
        configuration = {
            'app_port': 2000,
            'login_server': 'public1',
            'service_id': 'default',
            'version_id': 'v1',
            'env_vars': {}
        }

        version_details = {
            'runtime': 'python27',
            'revision': 1,
            'deployment': {
                'zip': {
                    'sourceUrl': 'source.tar.gz'
                }
            }
        }
        version_manager = flexmock(version_details=version_details)
        app_manager_server.projects_manager = {
            'test': {
                'default': {
                    'v1': version_manager
                }
            }
        }
        app_manager_server.deployment_config = flexmock(
            get_config=lambda x: {'default_max_appserver_memory': 400})

        source_manager = flexmock()
        response = Future()
        response.set_result(None)
        source_manager.should_receive('ensure_source'). \
          with_args('test_default_v1_1', 'source.tar.gz', 'python27'). \
          and_return(response)
        app_manager_server.source_manager = source_manager

        flexmock(monit_app_configuration).should_receive('create_config_file').\
          and_return('fakeconfig')
        flexmock(monit_interface).should_receive('start').\
          and_return(True)
        flexmock(app_manager_server).should_receive('wait_on_app').\
          and_return(True)
        flexmock(os).should_receive('popen').\
          and_return(flexmock(read=lambda: '12345\n'))
        flexmock(file_io).should_receive('write').\
          and_return()
        flexmock(threading).should_receive('Thread').\
          and_return(flexmock(start=lambda: None))
        flexmock(app_manager_server).should_receive(
            "setup_logrotate").and_return()

        app_manager_server.zk_client = flexmock()
        app_manager_server.zk_client.should_receive('ensure_path')
        yield app_manager_server.start_app('test_default_v1', configuration)
Exemplo n.º 10
0
  def test_start_app_goodconfig_java(self):
    configuration = {
      'app_port': 20000,
      'login_server': 'public1',
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_details = {'runtime': 'java',
                       'revision': 1,
                       'deployment': {'zip': {'sourceUrl': 'source.tar.gz'}}}
    version_manager = flexmock(version_details=version_details)
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}
    app_manager_server.deployment_config = flexmock(
      get_config=lambda x: {'default_max_appserver_memory': 400})

    source_manager = flexmock()
    response = Future()
    response.set_result(None)
    source_manager.should_receive('ensure_source').\
      with_args('test_default_v1_1', 'source.tar.gz', 'java').\
      and_return(response)
    app_manager_server.source_manager = source_manager

    start_cmd = ('/root/appscale/AppServer_Java/appengine-java-repacked/bin/'
                 'dev_appserver.sh --port 20000')
    flexmock(app_manager_server).should_receive('create_java_start_cmd').\
      and_return(start_cmd)

    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_return('fakeconfig')
    flexmock(monit_interface).should_receive('start').\
      and_return(True)
    flexmock(app_manager_server).should_receive('create_java_app_env').\
      and_return({})
    flexmock(app_manager_server).should_receive('wait_on_app').\
      and_return(True)
    flexmock(app_manager_server).should_receive('locate_dir').\
      and_return('/path/to/dir/')
    flexmock(os).should_receive('popen').\
      and_return(flexmock(read=lambda: '0\n'))
    flexmock(file_io).should_receive('write').and_return()
    flexmock(subprocess).should_receive('call').and_return(0)
    flexmock(threading).should_receive('Thread').\
      and_return(flexmock(start=lambda: None))
    flexmock(app_manager_server).should_receive("setup_logrotate").and_return()
    flexmock(os).should_receive('listdir').and_return([])

    app_manager_server.zk_client = flexmock()
    app_manager_server.zk_client.should_receive('ensure_path')
    yield app_manager_server.start_app('test_default_v1', configuration)
 def test_start_app_bad_appname(self):
   configuration = {'app_name': 'badName!@#$%^&*([]/.,',
                    'app_port': 2000,
                    'language': 'python27',
                    'load_balancer_ip': '127.0.0.1',
                    'load_balancer_port': 8080,
                    'xmpp_ip': '127.0.0.1',
                    'dblocations': ['127.0.0.1', '127.0.0.2'],
                    'env_vars': {},
                    'max_memory': 500}
   configuration = json.dumps(configuration)
   self.assertEqual(-1, app_manager_server.start_app(configuration)) 
Exemplo n.º 12
0
 def test_start_app_bad_appname(self):
     configuration = {
         "app_name": "badName!@#$%^&*([]/.,",
         "app_port": 2000,
         "language": "python27",
         "load_balancer_ip": "127.0.0.1",
         "load_balancer_port": 8080,
         "xmpp_ip": "127.0.0.1",
         "dblocations": ["127.0.0.1", "127.0.0.2"],
         "env_vars": {},
     }
     configuration = json.dumps(configuration)
     self.assertEqual(-1, app_manager_server.start_app(configuration))
Exemplo n.º 13
0
  def test_start_app_bad_appname(self):
    configuration = {
      'app_port': 2000,
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_manager = flexmock(version_details={'runtime': 'python27'})
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}

    with self.assertRaises(BadConfigurationException):
      yield app_manager_server.start_app(
        'badName!@#$%^&*([]/.,_default_v1', configuration)
Exemplo n.º 14
0
  def test_start_app_bad_appname(self):
    configuration = {
      'app_port': 2000,
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_manager = flexmock(version_details={'runtime': 'python27'})
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}

    with self.assertRaises(BadConfigurationException):
      yield app_manager_server.start_app(
        'badName!@#$%^&*([]/.,_default_v1', configuration)
Exemplo n.º 15
0
  def test_start_app_goodconfig_python(self):
    configuration = {
      'app_port': 2000,
      'login_server': 'public1',
      'service_id': 'default',
      'version_id': 'v1',
      'env_vars': {}
    }

    version_details = {'runtime': 'python27',
                       'revision': 1,
                       'deployment': {'zip': {'sourceUrl': 'source.tar.gz'}}}
    version_manager = flexmock(version_details=version_details)
    app_manager_server.projects_manager = {
      'test': {'default': {'v1': version_manager}}}
    app_manager_server.deployment_config = flexmock(
      get_config=lambda x: {'default_max_appserver_memory': 400})

    source_manager = flexmock()
    response = Future()
    response.set_result(None)
    source_manager.should_receive('ensure_source'). \
      with_args('test_default_v1_1', 'source.tar.gz', 'python27'). \
      and_return(response)
    app_manager_server.source_manager = source_manager

    flexmock(monit_app_configuration).should_receive('create_config_file').\
      and_return('fakeconfig')
    flexmock(monit_interface).should_receive('start').\
      and_return(True)
    flexmock(app_manager_server).should_receive('wait_on_app').\
      and_return(True)
    flexmock(os).should_receive('popen').\
      and_return(flexmock(read=lambda: '12345\n'))
    flexmock(file_io).should_receive('write').\
      and_return()
    flexmock(threading).should_receive('Thread').\
      and_return(flexmock(start=lambda: None))
    flexmock(app_manager_server).should_receive("setup_logrotate").and_return()

    app_manager_server.zk_client = flexmock()
    app_manager_server.zk_client.should_receive('ensure_path')
    yield app_manager_server.start_app('test_default_v1', configuration)
Exemplo n.º 16
0
    def test_start_app_goodconfig_java(self):
        configuration = {
            'app_name': 'test',
            'app_port': 2000,
            'language': 'java',
            'login_ip': '127.0.0.1',
            'load_balancer_port': 8080,
            'dblocations': ['127.0.0.1', '127.0.0.2'],
            'env_vars': {},
            'max_memory': 500
        }
        configuration = json.dumps(configuration)

        flexmock(appscale_info).should_receive('get_db_proxy').\
          and_return('<private_ip>')
        flexmock(appscale_info).should_receive('get_tq_proxy').\
          and_return('<private_ip>')
        flexmock(appscale_info).should_receive('get_private_ip').\
          and_return('<private_ip>')
        flexmock(monit_app_configuration).should_receive('create_config_file').\
          and_return('fakeconfig')
        flexmock(monit_interface).should_receive('start').\
          and_return(True)
        flexmock(app_manager_server).should_receive('create_java_app_env').\
          and_return({})
        flexmock(app_manager_server).should_receive('wait_on_app').\
          and_return(True)
        flexmock(app_manager_server).should_receive('locate_dir').\
          and_return('/path/to/dir/')
        flexmock(os).should_receive('popen').\
          and_return(flexmock(read=lambda: '0\n'))
        flexmock(file_io).should_receive('write').and_return()
        flexmock(subprocess).should_receive('call').and_return(0)
        flexmock(threading).should_receive('Thread').\
          and_return(flexmock(start=lambda: None))
        flexmock(app_manager_server).should_receive(
            "setup_logrotate").and_return()
        flexmock(os).should_receive('listdir').and_return([])
        self.assertEqual(0, app_manager_server.start_app(configuration))
Exemplo n.º 17
0
    def test_start_app_goodconfig_python(self):
        configuration = {
            "app_name": "test",
            "app_port": 2000,
            "language": "python27",
            "load_balancer_ip": "127.0.0.1",
            "load_balancer_port": 8080,
            "xmpp_ip": "127.0.0.1",
            "dblocations": ["127.0.0.1", "127.0.0.2"],
            "env_vars": {},
        }
        configuration = json.dumps(configuration)

        fake_secret = "XXXXXX"
        flexmock(appscale_info).should_receive("get_private_ip").and_return("<private_ip>")
        flexmock(appscale_info).should_receive("get_secret").and_return(fake_secret)
        flexmock(monit_app_configuration).should_receive("create_config_file").and_return("fakeconfig")
        flexmock(monit_interface).should_receive("start").and_return(True)
        flexmock(app_manager_server).should_receive("wait_on_app").and_return(True)
        flexmock(os).should_receive("popen").and_return(flexmock(read=lambda: "12345\n"))
        flexmock(file_io).should_receive("write").and_return()
        self.assertEqual(0, app_manager_server.start_app(configuration))
 def test_start_app_badconfig2(self):
   testing.disable_logging()
   self.assertEqual(app_manager_server.BAD_PID, app_manager_server.start_app("{'app_name':'test'}"))
 def test_start_app_badconfig(self):
   testing.disable_logging()
   self.assertEqual(app_manager_server.BAD_PID, app_manager_server.start_app({}))
Exemplo n.º 20
0
    def test_start_app_badconfig(self):
        testing.disable_logging()

        with self.assertRaises(BadConfigurationException):
            yield app_manager_server.start_app('test', {})
Exemplo n.º 21
0
  def test_start_app_badconfig(self):
    testing.disable_logging()

    with self.assertRaises(BadConfigurationException):
      yield app_manager_server.start_app('test', {})