当前位置: 首页>>代码示例>>Python>>正文


Python LoadSimulator.fromCommandLine方法代码示例

本文整理汇总了Python中contrib.performance.loadtest.sim.LoadSimulator.fromCommandLine方法的典型用法代码示例。如果您正苦于以下问题:Python LoadSimulator.fromCommandLine方法的具体用法?Python LoadSimulator.fromCommandLine怎么用?Python LoadSimulator.fromCommandLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在contrib.performance.loadtest.sim.LoadSimulator的用法示例。


在下文中一共展示了LoadSimulator.fromCommandLine方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_generateRecordsNonDefaultPatterns

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_generateRecordsNonDefaultPatterns(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to generate user records for use in the
     simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.generateRecords",
         "params": {
             "count": 3,
             "uidPattern": "USER%03d",
             "passwordPattern": "PASSWORD%03d",
             "namePattern": "Test User %03d",
             "emailPattern": "USER%[email protected]",
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(3, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'USER001')
     self.assertEqual(sim.records[0].password, 'PASSWORD001')
     self.assertEqual(sim.records[0].commonName, 'Test User 001')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[2].uid, 'USER003')
     self.assertEqual(sim.records[2].password, 'PASSWORD003')
     self.assertEqual(sim.records[2].commonName, 'Test User 003')
     self.assertEqual(sim.records[2].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:32,代码来源:test_sim.py

示例2: test_loadDefaultAccountsFromFile

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_loadDefaultAccountsFromFile(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader (with
     empty path)from the config file and uses it to create user
     records for use in the simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.recordsFromCSVFile",
         "params": {
             "path": ""
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(99, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'user01')
     self.assertEqual(sim.records[0].password, 'user01')
     self.assertEqual(sim.records[0].commonName, 'User 01')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[98].uid, 'user99')
     self.assertEqual(sim.records[98].password, 'user99')
     self.assertEqual(sim.records[98].commonName, 'User 99')
     self.assertEqual(sim.records[98].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:28,代码来源:test_sim.py

示例3: test_generateRecordsDefaultPatterns

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_generateRecordsDefaultPatterns(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to generate user records for use in the
     simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.generateRecords",
         "params": {
             "count": 2
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(2, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'user1')
     self.assertEqual(sim.records[0].password, 'user1')
     self.assertEqual(sim.records[0].commonName, 'User 1')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[1].uid, 'user2')
     self.assertEqual(sim.records[1].password, 'user2')
     self.assertEqual(sim.records[1].commonName, 'User 2')
     self.assertEqual(sim.records[1].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:28,代码来源:test_sim.py

示例4: test_loadPopulationParameters

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
    def test_loadPopulationParameters(self):
        """
        Client weights and profiles are loaded from the [clients]
        section of the configuration file specified.
        """
        config = FilePath(self.mktemp())
        config.setContent(writePlistToString({
                    "clients": [{
                            "software": "contrib.performance.loadtest.ical.OS_X_10_6",
                            "params": {"foo": "bar"},
                            "profiles": [{
                                    "params": {
                                        "interval": 25,
                                        "eventStartDistribution": {
                                            "type": "contrib.performance.stats.NormalDistribution",
                                            "params": {
                                                "mu": 123,
                                                "sigma": 456,
                                                }}},
                                    "class": "contrib.performance.loadtest.profiles.Eventer"}],
                            "weight": 3,
                            }]}))

        sim = LoadSimulator.fromCommandLine(
            ['--config', config.path, '--clients', config.path]
        )
        expectedParameters = PopulationParameters()
        expectedParameters.addClient(
            3, ClientType(OS_X_10_6, {"foo": "bar"}, [ProfileType(Eventer, {
                            "interval": 25,
                            "eventStartDistribution": NormalDistribution(123, 456)})]))
        self.assertEquals(sim.parameters, expectedParameters)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:34,代码来源:test_sim.py

示例5: test_loadAccountsFromFile

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_loadAccountsFromFile(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to create user records for use in the
     simulation.
     """
     accounts = FilePath(self.mktemp())
     accounts.setContent("foo,bar,baz,quux\nfoo2,bar2,baz2,quux2\n")
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.recordsFromCSVFile",
         "params": {
             "path": accounts.path
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     io = StringIO()
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path], io)
     self.assertEquals(io.getvalue(), "Loaded 2 accounts.\n")
     self.assertEqual(2, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'foo')
     self.assertEqual(sim.records[0].password, 'bar')
     self.assertEqual(sim.records[0].commonName, 'baz')
     self.assertEqual(sim.records[0].email, 'quux')
     self.assertEqual(sim.records[1].uid, 'foo2')
     self.assertEqual(sim.records[1].password, 'bar2')
     self.assertEqual(sim.records[1].commonName, 'baz2')
     self.assertEqual(sim.records[1].email, 'quux2')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:31,代码来源:test_sim.py

示例6: test_specifyRuntime

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_specifyRuntime(self):
     """
     L{LoadSimulator.fromCommandLine} recognizes the I{--runtime} option to
     specify a limit on how long the simulation will run.
     """
     config = FilePath(self.mktemp())
     config.setContent(VALID_CONFIG_PLIST)
     sim = LoadSimulator.fromCommandLine(['--config', config.path, '--runtime', '123'])
     self.assertEqual(123, sim.runtime)
开发者ID:nunb,项目名称:calendarserver,代码行数:11,代码来源:test_sim.py

示例7: test_loadServerConfig

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_loadServerConfig(self):
     """
     The Calendar Server host and port are loaded from the [server]
     section of the configuration file specified.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
                 "server": "https://127.0.0.3:8432/"}))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(sim.server, "https://127.0.0.3:8432/")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:12,代码来源:test_sim.py

示例8: test_loadLogObservers

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_loadLogObservers(self):
     """
     Log observers specified in the [observers] section of the
     configuration file are added to the logging system.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
         "observers": [{"type":"contrib.performance.loadtest.population.SimpleStatistics", "params":{}, }, ]
     }))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(len(sim.observers), 1)
     self.assertIsInstance(sim.observers[0], SimpleStatistics)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:test_sim.py

示例9: test_requireClient

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_requireClient(self):
     """
     At least one client is required, so if a configuration with an
     empty clients array is specified, a single default client type
     is used.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({"clients": []}))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     expectedParameters = PopulationParameters()
     expectedParameters.addClient(
         1, ClientType(OS_X_10_6, {}, [Eventer, Inviter, Accepter]))
     self.assertEquals(sim.parameters, expectedParameters)
开发者ID:azbarcea,项目名称:calendarserver,代码行数:15,代码来源:test_sim.py

示例10: test_loadArrivalConfig

# 需要导入模块: from contrib.performance.loadtest.sim import LoadSimulator [as 别名]
# 或者: from contrib.performance.loadtest.sim.LoadSimulator import fromCommandLine [as 别名]
 def test_loadArrivalConfig(self):
     """
     The arrival policy type and arguments are loaded from the
     [arrival] section of the configuration file specified.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
                 "arrival": {
                     "factory": "contrib.performance.loadtest.population.SmoothRampUp",
                     "params": {
                         "groups": 10,
                         "groupSize": 1,
                         "interval": 3,
                         },
                     },
                 }))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(
         sim.arrival,
         Arrival(SmoothRampUp, dict(groups=10, groupSize=1, interval=3)))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:22,代码来源:test_sim.py


注:本文中的contrib.performance.loadtest.sim.LoadSimulator.fromCommandLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。