~viswesn/juju-ci-tools/aws_boto3

« back to all changes in this revision

Viewing changes to tests/test_generate_perfscale_results.py

  • Committer: Christopher Lee
  • Date: 2016-10-26 04:59:52 UTC
  • mfrom: (1689 trunk)
  • mto: This revision was merged to the branch mainline in revision 1698.
  • Revision ID: chris.lee@canonical.com-20161026045952-g0l8ba05nmo5a638
Merge trunk. Fix conflict issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
        results_dir = 'results'
372
372
        name = 'testing_name'
373
373
        generator = Mock()
 
374
        graph_period = '0'
374
375
        with patch.object(
375
376
                gpr, 'create_report_graph', return_value=image) as m_crg:
376
377
            self.assertEqual(
377
378
                image,
378
379
                gpr.generate_graph_image(
379
 
                    base_dir, results_dir, name, generator))
 
380
                    base_dir, results_dir, name, generator, graph_period))
380
381
        m_crg.assert_called_once_with(
381
 
            '/foo/test/results', '/foo/test/test-testing_name.png', generator)
 
382
            '/foo/test/results',
 
383
            '/foo/test/test-testing_name.png',
 
384
            generator,
 
385
            graph_period)
382
386
 
383
387
    def test_generate_cpu_graph(self):
384
388
        image = Mock()
 
389
        graph_period = '0'
385
390
        with self.patch_image_creation_ctx(image) as m_ggi:
386
391
            self.assertEqual(
387
392
                image,
388
 
                gpr.generate_cpu_graph_image('/foo'))
 
393
                gpr.generate_cpu_graph_image('/foo', graph_period))
389
394
        m_ggi.assert_called_once_with(
390
 
            '/foo', 'aggregation-cpu-average', 'cpu', perf_graphing.cpu_graph)
 
395
            '/foo',
 
396
            'aggregation-cpu-max',
 
397
            'cpu',
 
398
            perf_graphing.cpu_graph,
 
399
            graph_period)
391
400
 
392
401
    def test_generate_memory_graph_calls_(self):
393
402
        image = Mock()
 
403
        graph_period = '0'
394
404
        with self.patch_image_creation_ctx(image) as m_ggi:
395
405
            self.assertEqual(
396
406
                image,
397
 
                gpr.generate_memory_graph_image('/foo'))
 
407
                gpr.generate_memory_graph_image('/foo', graph_period))
398
408
        m_ggi.assert_called_once_with(
399
 
            '/foo', 'memory', 'memory', perf_graphing.memory_graph)
 
409
            '/foo',
 
410
            'memory',
 
411
            'memory',
 
412
            perf_graphing.memory_graph,
 
413
            graph_period)
400
414
 
401
415
    def test_generate_network_graph(self):
402
416
        image = Mock()
 
417
        graph_period = '0'
403
418
        with self.patch_image_creation_ctx(image) as m_ggi:
404
419
            self.assertEqual(
405
420
                image,
406
 
                gpr.generate_network_graph_image('/foo'))
 
421
                gpr.generate_network_graph_image('/foo', graph_period))
407
422
        m_ggi.assert_called_once_with(
408
 
            '/foo', 'interface-eth0', 'network', perf_graphing.network_graph)
 
423
            '/foo',
 
424
            'interface-eth0',
 
425
            'network',
 
426
            perf_graphing.network_graph,
 
427
            graph_period)
409
428
 
410
429
    def test_generate_mongo_query_graph(self):
411
430
        image = Mock()
 
431
        graph_period = '0'
412
432
        with self.patch_image_creation_ctx(image) as m_ggi:
413
433
            self.assertEqual(
414
434
                image,
415
 
                gpr.generate_mongo_query_graph_image('/foo'))
 
435
                gpr.generate_mongo_query_graph_image('/foo', graph_period))
416
436
        m_ggi.assert_called_once_with(
417
 
            '/foo', 'mongodb', 'mongodb', perf_graphing.mongodb_graph)
 
437
            '/foo',
 
438
            'mongodb',
 
439
            'mongodb',
 
440
            perf_graphing.mongodb_graph,
 
441
            graph_period)
418
442
 
419
443
    def test_generate_mongo_memory_graph(self):
420
444
        image = Mock()
 
445
        graph_period = '0'
421
446
        with self.patch_image_creation_ctx(image) as m_ggi:
422
447
            self.assertEqual(
423
448
                image,
424
 
                gpr.generate_mongo_memory_graph_image('/foo'))
 
449
                gpr.generate_mongo_memory_graph_image('/foo', graph_period))
425
450
        m_ggi.assert_called_once_with(
426
451
            '/foo',
427
452
            'mongodb',
428
453
            'mongodb_memory',
429
 
            perf_graphing.mongodb_memory_graph)
 
454
            perf_graphing.mongodb_memory_graph,
 
455
            graph_period)
430
456
 
431
457
    def test_create_report_graph_returns_base_file_path(self):
432
458
        """The returned filepath should just be the basename."""
437
463
        rrd_dir = '/foo'
438
464
        output_file = '/bar/test.png'
439
465
        output_file_base = 'test.png'
 
466
        graph_period = '0'
440
467
 
441
468
        with patch.object(
442
469
                gpr.os, 'listdir',
446
473
                    autospec=True, return_value=(start, end)) as m_gdp:
447
474
                self.assertEqual(
448
475
                    output_file_base,
449
 
                    gpr.create_report_graph(rrd_dir, output_file, generator)
 
476
                    gpr.create_report_graph(
 
477
                        rrd_dir, output_file, generator, graph_period)
450
478
                )
451
 
        m_gdp.assert_called_once_with('/foo/example.rrd')
 
479
        m_gdp.assert_called_once_with('/foo/example.rrd', graph_period)
452
480
        m_list.assert_called_once_with(rrd_dir)
453
 
        generator.assert_called_once_with(start, end, rrd_dir, output_file)
 
481
        generator.assert_called_once_with(
 
482
            start, end, rrd_dir, output_file)
454
483
 
455
484
 
456
485
class TestFindActualStart(TestCase):