Ejemplo n.º 1
0
 def test_probe_spark_conf_value_default_value(self):
     parse_conf_before_probe()
     conf_name = "Whatever~"
     default_value = "RIGHT_ANSWER"
     answer = load_config.probe_spark_conf_value(conf_name, default_value)
     expected = default_value
     self.assertEqual(answer, expected)
Ejemplo n.º 2
0
 def test_probe_spark_conf_value_default_value(self):
     parse_conf_before_probe()
     conf_name = "Whatever~"
     default_value = "RIGHT_ANSWER"
     answer = load_config.probe_spark_conf_value(conf_name, default_value)
     expected = default_value
     self.assertEqual(answer, expected)
Ejemplo n.º 3
0
        def test(self):
            load_config.HibenchConf[
                "hibench.spark.home"] = "/tmp/test/spark_home"

            conf_name = spark_conf_test_case_list[case_num][1]
            line = spark_conf_test_case_list[case_num][2]
            default = spark_conf_test_case_list[case_num][3]

            def read_file_content(filepath):
                if filepath == "/tmp/test/spark_home/conf/spark-env.sh":
                    return [line]
                else:
                    return []

            mock_read_file_content = mock.Mock(side_effect=read_file_content)
            with mock.patch("load_config.read_file_content",
                            mock_read_file_content):
                answer = ""

                try:
                    from load_config import probe_spark_conf_value
                    answer = probe_spark_conf_value(conf_name, default)
                except:
                    pass
                expected = default
                if len(line.split("=")) >= 2:
                    expected = line.split("=")[1]
                expected = expected.strip("\'")
                expected = expected.strip("\"")
                self.assertEqual(str(answer), expected)
Ejemplo n.º 4
0
        def test(self):
            load_config.HibenchConf[
                "hibench.spark.home"] = "/tmp/test/spark_home"

            conf_name = spark_conf_test_case_list[case_num][1]
            line = spark_conf_test_case_list[case_num][2]
            default = spark_conf_test_case_list[case_num][3]

            def read_file_content(filepath):
                if filepath == "/tmp/test/spark_home/conf/spark-env.sh":
                    return [line]
                else:
                    return []

            mock_read_file_content = mock.Mock(side_effect=read_file_content)
            with mock.patch("load_config.read_file_content",
                            mock_read_file_content):
                answer = ""

                try:
                    from load_config import probe_spark_conf_value
                    answer = probe_spark_conf_value(conf_name, default)
                except:
                    pass
                expected = default
                if len(line.split("=")) >= 2:
                    expected = line.split("=")[1]
                expected = expected.strip("\'")
                expected = expected.strip("\"")
                self.assertEqual(str(answer), expected)