예제 #1
0
def test_generate_commits():
    start_time = datetime(year=2018, month=4, day=3, hour=9)
    commits = generate_commits(100, start_time, offset=1, max_interval=30)
    assert len(commits) == 100
    assert commits[0].name == "#0001"
    assert commits[0].time == start_time
    assert commits[-1].name == "#0100"
def test_simulation():
    stages = [
        Stage("Build & Unit Test",
              duration=timedelta(minutes=10),
              failure_rate=0.02),
        Stage("System Test", duration=timedelta(minutes=20), failure_rate=0.2),
        Stage("Performance Test",
              duration=timedelta(minutes=120),
              failure_rate=0.1,
              single_threaded=True),
    ]

    start_time = datetime(year=2017, month=12, day=11, hour=8)
    commits = generate_commits(100, start_time, offset=2000, max_interval=100)
    deployer = Deployer(duration=timedelta(minutes=2),
                        deploy_policy=DeployPolicy.EveryPassing)
    runs = run_simulation(start_time,
                          stages,
                          commits=commits,
                          deployer=deployer)
    assert len(runs) <= 100
예제 #3
0
def test_generate_commits_during_working_hours():
    start_time = datetime(year=2018, month=4, day=3, hour=17, minute=59)
    commits = generate_commits(2, start_time, offset=1, max_interval=30)
    assert start_time < commits[1].time
    assert commits[1].time > datetime(year=2018, month=4, day=4, hour=8)
stages = [
    Stage("Commit Stage", duration=timedelta(minutes=3), failure_rate=0.005),
    Stage("Automated Acceptance Test",
          duration=timedelta(minutes=20),
          failure_rate=0.01),
    Stage("Performance Test",
          duration=timedelta(minutes=20),
          failure_rate=0.01),
    Stage("Internal Release",
          duration=timedelta(minutes=4),
          failure_rate=0.01,
          single_threaded=True),
]

start_time = datetime(year=2017, month=12, day=11, hour=8)

commits = generate_commits(100, start_time, offset=2000, max_interval=100)

deployer = Deployer(duration=timedelta(minutes=4),
                    deploy_policy=DeployPolicy.OnceADay,
                    deploy_hour=17,
                    deploy_day=6)

runs = run_simulation(start_time, stages, commits=commits, deployer=deployer)
print_runs("simulation_farley", stages, runs)

metrics_calc = MetricsCalculator(runs)
metrics = metrics_calc.metrics()
print_metrics("simulation_farley", metrics)
print(metrics.pretty_print())