def testRunReturnsCorrectlyParsedSamples(self,
                                           mock_getopenfoamversion,
                                           mock_getmpiversion):
    # Run with mocked output data
    self.mock_vm.RemoteCommand.return_value = None, '\n'.join(
        ['real    4m1.419s', 'user    23m11.198s', 'sys     0m25.274s'])
    self.mock_vm.NumCpusForBenchmark.return_value = 8
    samples = openfoam_benchmark.Run(self.mock_benchmark_spec)

    # Verify command is what we expected to run
    run_cmd = [
        'cd $HOME/OpenFOAM/run/motorBike',
        './Allclean',
        'time ./Allrun'
    ]
    self.mock_vm.RemoteCommand.assert_called_with(' && '.join(run_cmd))

    # Verify sample equality
    expected_metadata = {
        'case_name': 'motorbike',
        'dimensions': '80 32 32',
        'total_cpus_available': 8,
        'total_cpus_used': 4,
        'openfoam_version': '7',
        'openmpi_version': '1.10.2',
        'mpi_mapping': 'core:SPAN',
    }
    unit = 'seconds'
    self.assertSamplesEqualUpToTimestamp(
        sample.Sample('time_real', 241, unit, expected_metadata), samples[0])
    self.assertSamplesEqualUpToTimestamp(
        sample.Sample('time_user', 1391, unit, expected_metadata), samples[1])
    self.assertSamplesEqualUpToTimestamp(
        sample.Sample('time_sys', 25, unit, expected_metadata), samples[2])
Exemplo n.º 2
0
    def testRunWithMoreFlags(self, mock_runcase, mock_setdict, mock_usempi):
        self.mock_vm.NumCpusForBenchmark.return_value = 16
        test_sample = sample.Sample('mock', 0, 'mock')
        mock_runcase.return_value = [test_sample]

        samples = openfoam_benchmark.Run(self.mock_benchmark_spec)

        mock_runcase.assert_called_with(self.mock_vm, '120_48_48')

        setdict_calls = [
            ('method', 'simple', 'system/decomposeParDict'),
            ('numberOfSubdomains', 8, 'system/decomposeParDict'),
            ('hierarchicalCoeffs.n', '(8 1 1)', 'system/decomposeParDict'),
            ('castellatedMeshControls.maxGlobalCells', float(1e9),
             'system/snappyHexMeshDict'),
        ]
        mock_setdict.assert_has_calls([
            mock.call(self.mock_vm, key, value, dict_file_name)
            for key, value, dict_file_name in setdict_calls
        ])

        mock_usempi.assert_called_with(self.mock_vm, 8, 'hwthread')

        self.assertLen(samples, 1)
        expected_metadata = {
            'case_name': 'motorbike',
            'decomp_method': 'simple',
            'max_global_cells': 1000000000.0,
            'mpi_mapping': 'hwthread',
            'openfoam_version': '7',
            'openmpi_version': '1.10.2',
            'total_cpus_available': 16,
            'total_cpus_used': 8,
        }
        self.assertEqual(expected_metadata, samples[0].metadata)
Exemplo n.º 3
0
    def testRunReturnsCorrectlyParsedSamples(self, mock_getopenfoamversion,
                                             mock_getmpiversion):
        # Run with mocked output data
        self.mock_vm.RemoteCommand.return_value = None, '\n'.join(
            ['real    4m1.419s', 'user    23m11.198s', 'sys     0m25.274s'])
        samples = openfoam_benchmark.Run(self.benchmark_spec)

        # Verify command is what we expected to run
        run_cmd = [
            'source /opt/openfoam7/etc/bashrc',
            'cd $HOME/Openfoam/${USER}-7/run/motorBike', './Allclean',
            'time ./Allrun'
        ]
        self.mock_vm.RemoteCommand.assert_called_with(' && '.join(run_cmd))

        # Verify sample equality
        expected_metadata = {
            'case': 'motorbike',
            'openfoam_version': '7',
            'openmpi_version': '1.10.2'
        }
        unit = 'seconds'
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_real', 241.0, unit, expected_metadata),
            samples[0])
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_user', 1391.0, unit, expected_metadata),
            samples[1])
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_sys', 25.0, unit, expected_metadata),
            samples[2])
    def testRunCaseReturnsCorrectlyParsedSamples(self, mock_getopenfoamversion,
                                                 mock_getmpiversion,
                                                 mock_parseruncommands):
        # Run with mocked output data
        self.mock_vm.RemoteCommand.return_value = None, '\n'.join(
            ['real 131.64', 'user 327.05', 'sys 137.04'])
        self.mock_vm.NumCpusForBenchmark.return_value = 8
        samples = openfoam_benchmark.Run(self.mock_benchmark_spec)

        # Verify command is what we expected to run
        run_cmd = [
            'cd $HOME/OpenFOAM/run/motorBike',
            'time -p mpirun $(getApplication)'
        ]
        self.mock_vm.RemoteCommand.assert_called_with(' && '.join(run_cmd))

        # Verify sample equality
        expected_metadata = {
            'case_name': 'motorbike',
            'command': '$(getApplication)',
            'decomp_method': 'scotch',
            'dimensions': '80_32_32',
            'full_command': 'mpirun $(getApplication)',
            'max_global_cells': 200000000,
            'mpi_mapping': 'core:SPAN',
            'openfoam_version': '7',
            'openmpi_version': '1.10.2',
            'total_cpus_available': 8,
            'total_cpus_used': 4,
        }
        unit = 'seconds'
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_real', 131, unit, expected_metadata),
            samples[0])
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_user', 327, unit, expected_metadata),
            samples[1])
        self.assertSamplesEqualUpToTimestamp(
            sample.Sample('time_sys', 137, unit, expected_metadata),
            samples[2])