Ejemplo n.º 1
0
    def test_app_c_restart(self):
        name = "random_name"
        profile_name = "random_profile"
        result = io.run_sync(app.Restart(self.node, self.locator, name,
                                         profile_name).execute,
                             timeout=2)

        assert "application `random_name` has been restarted with profile `random_profile`" == result, result
Ejemplo n.º 2
0
    def test_AppRestartActionAppIsNotRunningProfileIsNotSpecified(self):
        node = mock()
        action = app.Restart(node, **{'name': 'AppName', 'host': '', 'port': ''})
        when(common.NodeInfo).execute().thenReturn(Chain([lambda: {
            'apps': {}
        }]))

        when(app.Stop).execute().thenReturn(Chain([lambda: {'AppName': 'NotRunning'}]))
        when(app.Start).execute().thenReturn(Chain([lambda: {'AppName': 'Started'}]))
        self.assertRaises(ToolsError, action.execute().get)

        verify(common.NodeInfo).execute()
Ejemplo n.º 3
0
    def test_AppRestartActionAppIsRunningProfileIsSpecified(self):
        node = mock()
        action = app.Restart(node, **{'name': 'AppName', 'profile': 'NewProfile', 'host': '', 'port': ''})
        when(common.NodeInfo).execute().thenReturn(Chain([lambda: {
            'apps': {
                'AppName': {
                    'profile': 'ProfileName',
                    'state': 'running',
                }
            }
        }]))

        when(app.Stop).execute().thenReturn(Chain([lambda: {'AppName': 'Stopped'}]))
        when(app.Start).execute().thenReturn(Chain([lambda: {'AppName': 'Started'}]))
        action.execute().get()

        verify(common.NodeInfo).execute()
        verify(app.Stop).execute()
        verify(app.Start).execute()
Ejemplo n.º 4
0
    def test_AppRestartActionAppIsRunningProfileIsNotSpecified(self):
        node = mock()
        locator = mock()
        action = app.Restart(node, locator, **{'name': 'AppName', 'profile': 'default'})
        when(common.NodeInfo).execute().thenReturn(Chain([lambda: {
            'apps': {
                'AppName': {
                    'profile': 'ProfileName',
                    'state': 'running',
                }
            }
        }]))

        when(app.Stop).execute().thenReturn(Chain([lambda: {'AppName': 'Stopped'}]))
        when(app.Start).execute().thenReturn(Chain([lambda: {'AppName': 'Started'}]))
        action.execute().get(timeout=0.1)

        verify(common.NodeInfo).execute()
        verify(app.Stop).execute()
        verify(app.Start).execute()
Ejemplo n.º 5
0
 def test_restart_no_such_app(self):
     io.run_sync(app.Restart(self.node, self.locator, "no_such_app_name",
                             None).execute,
                 timeout=2)
Ejemplo n.º 6
0
 def test_restart_no_name(self):
     app.Restart(self.node, self.locator, "", "dummy_profile_name")