Beispiel #1
0
 def test_add_all_options(self):
     self.config.corosync_conf.load_content(fixture_totem())
     self.config.env.push_corosync_conf(
         corosync_conf_text=fixture_totem(
             transport_options=TRANSPORT_OPTIONS,
             compression_options=COMPRESSION_OPTIONS,
             crypto_options=CRYPTO_OPTIONS,
             totem_options=TOTEM_OPTIONS,
         ),
         need_stopped_cluster=True,
     )
     cluster.config_update(
         self.env_assist.get_env(),
         TRANSPORT_OPTIONS,
         COMPRESSION_OPTIONS,
         CRYPTO_OPTIONS,
         TOTEM_OPTIONS,
     )
     self.env_assist.assert_reports([])
Beispiel #2
0
 def _test_modify(self, transport_options, need_stopped_cluster):
     self.config.corosync_conf.load_content(
         fixture_totem(
             transport_options=TRANSPORT_OPTIONS,
             compression_options=COMPRESSION_OPTIONS,
             crypto_options=CRYPTO_OPTIONS,
             totem_options=TOTEM_OPTIONS,
         )
     )
     modified_transport_options = dict(TRANSPORT_OPTIONS)
     modified_transport_options.update(transport_options)
     modified_compression_options = {
         "level": "9",
         "model": "lz4",
         "threshold": "100",
     }
     modified_crypto_options = {
         "cipher": "aes128",
         "hash": "sha512",
         "model": "openssl",
     }
     modified_totem_options = {
         opt: ("no" if opt == "block_unlisted_ips" else val + "0")
         for opt, val in TOTEM_OPTIONS.items()
     }
     self.config.env.push_corosync_conf(
         corosync_conf_text=fixture_totem(
             transport_options=modified_transport_options,
             compression_options=modified_compression_options,
             crypto_options=modified_crypto_options,
             totem_options=modified_totem_options,
         ),
         need_stopped_cluster=need_stopped_cluster,
     )
     cluster.config_update(
         self.env_assist.get_env(),
         modified_transport_options,
         modified_compression_options,
         modified_crypto_options,
         modified_totem_options,
     )
     self.env_assist.assert_reports([])
Beispiel #3
0
 def test_udp_transport_unsupported_options(self):
     self.config.corosync_conf.load_content(
         fixture_totem(transport_type="udp"))
     self.env_assist.assert_raise_library_error(
         lambda: cluster.config_update(
             self.env_assist.get_env(),
             {"knet_pmtud_interval": "interval"},
             {
                 "level": "high",
                 "unknown": "val"
             },
             {
                 "cipher": "strong",
                 "unknown": "val"
             },
             {"downcheck": "check"},
         ))
     self.env_assist.assert_reports([
         fixture.error(
             report_codes.INVALID_OPTION_VALUE,
             option_name="downcheck",
             option_value="check",
             allowed_values="a non-negative integer",
             cannot_be_empty=False,
             forbidden_characters=None,
         ),
         fixture.error(
             report_codes.INVALID_OPTIONS,
             option_names=["knet_pmtud_interval"],
             option_type="udp/udpu transport",
             allowed=["ip_version", "netmtu"],
             allowed_patterns=[],
         ),
         fixture.error(
             report_codes.COROSYNC_TRANSPORT_UNSUPPORTED_OPTIONS,
             option_type="compression",
             actual_transport="udp/udpu",
             required_transports=["knet"],
         ),
         fixture.error(
             report_codes.COROSYNC_TRANSPORT_UNSUPPORTED_OPTIONS,
             option_type="crypto",
             actual_transport="udp/udpu",
             required_transports=["knet"],
         ),
     ])
Beispiel #4
0
 def test_unsupported_transport(self):
     self.config.corosync_conf.load_content(
         fixture_totem(transport_type="keynet"))
     self.env_assist.assert_raise_library_error(
         lambda: cluster.config_update(
             self.env_assist.get_env(),
             {
                 "unknown": "val",
                 "ip_version": "4"
             },
             {
                 "level": "high",
                 "unknown": "val"
             },
             {
                 "cipher": "strong",
                 "unknown": "val"
             },
             {
                 "unknown": "val",
                 "downcheck": "check"
             },
         ))
     self.env_assist.assert_reports([
         fixture.error(
             report_codes.INVALID_OPTIONS,
             option_names=["unknown"],
             option_type="totem",
             allowed=ALLOWED_TOTEM_OPTIONS,
             allowed_patterns=[],
         ),
         fixture.error(
             report_codes.COROSYNC_CONFIG_UNSUPPORTED_TRANSPORT,
             actual_transport="keynet",
             supported_transport_types=["knet", "udp", "udpu"],
         ),
         fixture.error(
             report_codes.INVALID_OPTION_VALUE,
             option_name="downcheck",
             option_value="check",
             allowed_values="a non-negative integer",
             cannot_be_empty=False,
             forbidden_characters=None,
         ),
     ])
Beispiel #5
0
 def test_no_changed_options(self):
     self.config.corosync_conf.load_content(fixture_totem())
     self.config.env.push_corosync_conf(corosync_conf_text=fixture_totem())
     cluster.config_update(self.env_assist.get_env(), {}, {}, {}, {})
     self.env_assist.assert_reports([])
Beispiel #6
0
 def get_lib_command(self):
     return lambda: cluster.config_update(
         self.env_assist.get_env(), {}, {}, {}, {}
     )
Beispiel #7
0
 def test_unknown_options_and_values(self):
     self.config.corosync_conf.load_content(fixture_totem())
     self.env_assist.assert_raise_library_error(
         lambda: cluster.config_update(
             self.env_assist.get_env(),
             {"unknown": "val", "ip_version": "4"},
             {"level": "high", "unknown": "val"},
             {"cipher": "strong", "unknown": "val"},
             {"unknown": "val", "downcheck": "check"},
         )
     )
     self.env_assist.assert_reports(
         [
             fixture.error(
                 report_codes.INVALID_OPTIONS,
                 option_names=["unknown"],
                 option_type="totem",
                 allowed=ALLOWED_TOTEM_OPTIONS,
                 allowed_patterns=[],
             ),
             fixture.error(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="downcheck",
                 option_value="check",
                 allowed_values="a non-negative integer",
                 cannot_be_empty=False,
                 forbidden_characters=None,
             ),
             fixture.error(
                 report_codes.INVALID_OPTIONS,
                 option_names=["unknown"],
                 option_type="knet transport",
                 allowed=ALLOWED_KNET_TRANSPORT_OPTIONS,
                 allowed_patterns=[],
             ),
             fixture.error(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="ip_version",
                 option_value="4",
                 allowed_values=("ipv4", "ipv6", "ipv4-6", "ipv6-4"),
                 cannot_be_empty=False,
                 forbidden_characters=None,
             ),
             fixture.error(
                 report_codes.INVALID_OPTIONS,
                 option_names=["unknown"],
                 option_type="compression",
                 allowed=ALLOWED_COMPRESSION_OPTIONS,
                 allowed_patterns=[],
             ),
             fixture.error(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="level",
                 option_value="high",
                 allowed_values="a non-negative integer",
                 cannot_be_empty=False,
                 forbidden_characters=None,
             ),
             fixture.error(
                 report_codes.INVALID_OPTIONS,
                 option_names=["unknown"],
                 option_type="crypto",
                 allowed=ALLOWED_CRYPTO_OPTIONS,
                 allowed_patterns=[],
             ),
             fixture.error(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="cipher",
                 option_value="strong",
                 allowed_values=("none", "aes256", "aes192", "aes128"),
                 cannot_be_empty=False,
                 forbidden_characters=None,
             ),
             fixture.error(
                 report_codes.PREREQUISITE_OPTION_MUST_BE_ENABLED_AS_WELL,
                 option_name="cipher",
                 prerequisite_name="hash",
                 option_type="crypto",
                 prerequisite_type="crypto",
             ),
         ]
     )