Ejemplo n.º 1
0
    def test_client_server_with_autoscaling(self):
        self.file_system.define(
            "test.mad",
            "service DB {"
            "   settings {"
            "      autoscaling {"
            "          period: 10"
            "          limits: [3, 6]"
            "      }"
            "   }"
            "   operation Select {"
            "      think 9"
            "   }"
            "}"
            "client Browser {"
            "  every 2 {"
            "      query DB/Select"
            "  }"
            "}")

        controller = Controller(StringIO(), self.file_system)
        simulation = controller.execute("test.mad", "115")

        server = simulation.environment.look_up("DB")
        worker_pool = server.environment.look_up(Symbols.WORKER_POOL)
        self.assertEqual(5, worker_pool.capacity)
Ejemplo n.º 2
0
    def test_client_server_with_autoscaling(self):
        self.file_system.define(
            "test.mad", "service DB {"
            "   settings {"
            "      autoscaling {"
            "          period: 10"
            "          limits: [3, 6]"
            "      }"
            "   }"
            "   operation Select {"
            "      think 9"
            "   }"
            "}"
            "client Browser {"
            "  every 2 {"
            "      query DB/Select"
            "  }"
            "}")

        controller = Controller(StringIO(), self.file_system)
        simulation = controller.execute("test.mad", "115")

        server = simulation.environment.look_up("DB")
        worker_pool = server.environment.look_up(Symbols.WORKER_POOL)
        self.assertEqual(5, worker_pool.capacity)
Ejemplo n.º 3
0
    def test_sensapp(self):
        with open(
                "C:/Users/franckc/home/projects/diversify/dev/mad/samples/sensapp/sensapp.mad"
        ) as source:
            self.file_system.define("test.mad", source.read())

        controller = Controller(StringIO(), self.file_system)
        simulation = controller.execute("test.mad", "200")
Ejemplo n.º 4
0
    def test_loading(self):
        Arguments._identifier = lambda s: "1"

        self.file_system.define(
            self.MAD_FILE,
            "service DB {"
            "  operation Select {"
            "      think 5"
            "   }"
            "}"
            "client Browser {"
            "  every 10 {"
            "      query DB/Select"
            "   }"
            "}")

        controller = Controller(StringIO(), self.file_system)

        controller.execute("test.mad", "25")

        data = self.file_system.opened_files["test_1/DB.log"].getvalue().split("\n")
        self.assertEqual(4, len(data), data) # header line, + Monitoring at 10, 20 + newline
    def test_loading(self):
        Arguments._identifier = lambda s: "1"

        self.file_system.define(
            self.MAD_FILE, "service DB {"
            "  operation Select {"
            "      think 5"
            "   }"
            "}"
            "client Browser {"
            "  every 10 {"
            "      query DB/Select"
            "   }"
            "}")

        controller = Controller(StringIO(), self.file_system)

        controller.execute("test.mad", "25")

        data = self.file_system.opened_files["test_1/DB.log"].getvalue().split(
            "\n")
        self.assertEqual(4, len(data),
                         data)  # header line, + Monitoring at 10, 20 + newline
Ejemplo n.º 6
0
#!/usr/bin/env python

#
# This file is part of MAD.
#
# MAD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MAD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MAD.  If not, see <http://www.gnu.org/licenses/>.
#

from sys import argv, stdout

from mad.storage import FileSystem
from mad.ui import Controller

controller = Controller(stdout, FileSystem())
controller.execute(*argv[1:])
Ejemplo n.º 7
0
 def _execute(self, command_line = None):
     if not command_line:
         command_line = [self.LOCATION, 1000]
     mad = Controller(self.display, self.file_system)
     self.simulation = mad.execute(*command_line)
Ejemplo n.º 8
0
    def test_sensapp(self):
        with open("C:/Users/franckc/home/projects/diversify/dev/mad/samples/sensapp/sensapp.mad") as source:
            self.file_system.define("test.mad", source.read())

        controller = Controller(StringIO(), self.file_system)
        simulation = controller.execute("test.mad", "200")
Ejemplo n.º 9
0
 def _execute(self, command_line = None):
     if not command_line:
         command_line = [self.LOCATION, 1000]
     mad = Controller(self.display, self.file_system)
     self.simulation = mad.execute(*command_line)
Ejemplo n.º 10
0
#!/usr/bin/env python

#
# This file is part of MAD.
#
# MAD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MAD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MAD.  If not, see <http://www.gnu.org/licenses/>.
#

from sys import argv, stdout

from mad.storage import FileSystem
from mad.ui import Controller


controller = Controller(stdout, FileSystem())
controller.execute(*argv[1:])