Skip to content

Split IO tests into multiple modules #4946

@taimoorzaeem

Description

@taimoorzaeem

Right now, test_io.py is huge (2100+ lines) and it contains all kinds of tests. This comes in the way of improving out test infrastructure in light of #4868. We should discuss splitting them into multiple modules. Eventually we should remove the test_io.py so tests only go to a more appropriate module.

Combining test_io.py and test_auth.py on main branch, we have a total of 105 test functions.

Maybe we should divide these as follows?

# test_admin.py
def test_admin_live_dependent_on_main_app(defaultenv):
def test_admin_live_good(defaultenv):
def test_admin_metrics(defaultenv):
def test_admin_metrics_exclude_ghc_runtime_metrics_by_default(defaultenv):
def test_admin_metrics_include_ghc_runtime_metrics(defaultenv):
def test_admin_not_found(defaultenv):
def test_admin_ready_dependent_on_main_app(defaultenv):
def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
def test_admin_ready_w_channel(defaultenv):
def test_admin_ready_wo_channel(defaultenv):
def test_admin_schema_cache(defaultenv):
def test_admin_works_with_host_special_values(specialhostvalue, defaultenv):
def test_metrics_include_schema_cache_fails(defaultenv, metapostgrest):
# test_reloading.py
def test_app_settings_reload(tmp_path, defaultenv):
def test_db_schema_notify_reload(defaultenv):
def test_db_schema_reload(tmp_path, defaultenv):
def test_invalid_role_claim_key_notify_reload(defaultenv):
def test_max_rows_notify_reload(defaultenv):
def test_max_rows_reload(defaultenv):
def test_no_double_schema_cache_reload_on_empty_schema(defaultenv):
def test_notify_reloading_catalog_cache(defaultenv):
def test_notify_do_nothing(defaultenv):
def test_schema_cache_concurrent_notifications(slow_schema_cache_env):
def test_jwt_secret_reload(tmp_path, defaultenv):
def test_jwt_secret_external_file_reload(tmp_path, defaultenv):
def test_invalidate_jwt_cache_when_secret_changes(tmp_path, defaultenv):
# test_connection.py - related to startup and connection pools
def test_fail_with_invalid_password(defaultenv):
def test_read_secret_from_file(secretpath, defaultenv):
def test_read_secret_from_stdin(defaultenv):
def test_read_secret_from_stdin_dbconfig(defaultenv):
def test_connect_with_dburi(dburi, defaultenv):
def test_get_pgrst_version_with_keyval_connection_string(defaultenv):
def test_get_pgrst_version_with_uri_connection_string(dburi_type, dburi, defaultenv):
def test_fail_with_invalid_dbname_and_automatic_recovery_disabled(defaultenv):
def test_read_dburi_from_stdin_with_eol(dburi, defaultenv):
def test_read_dburi_from_stdin_without_eol(dburi, defaultenv):
def test_app_settings_flush_pool(defaultenv):
def test_flush_pool_no_interrupt(defaultenv):
def test_no_pool_connection_required_on_bad_embedding(defaultenv):
def test_no_pool_connection_required_on_bad_http_logic(defaultenv):
def test_no_pool_connection_required_on_bad_jwt_claim(defaultenv):
def test_no_pool_connection_required_on_options(defaultenv):
def test_pool_acquisition_timeout(level, defaultenv, metapostgrest):
def test_pool_acquisition_timeout_logs_are_debounced(defaultenv):
def test_pool_size(defaultenv, metapostgrest):
def test_positive_pool_metric(defaultenv):
def test_random_port_bound(defaultenv):
def test_so_reuseport_zero_downtime_handover(defaultenv):
# test_cors.py
def test_no_preflight_request_with_CORS_config_should_not_return_header(defaultenv):
def test_no_preflight_request_with_CORS_config_should_return_header(defaultenv):
def test_options_request_logs_but_cors_preflight_does_not(defaultenv):
def test_preflight_request_with_cors_allowed_origin_config(defaultenv):
def test_preflight_request_with_empty_cors_allowed_origin_config(defaultenv):
# test_log.py - Logs, Error Messages and Observations 
def test_log_error_when_empty_schema_cache_on_startup_to_stderr(defaultenv):
def test_log_lacks_role_with_empty_anon_role(defaultenv):
def test_log_level(level, defaultenv):
def test_log_listener_connection_errors(defaultenv):
def test_log_listener_connection_start(defaultenv):
def test_log_pool_req_observation(level, defaultenv):
def test_log_postgrest_host_and_port(host, defaultenv):
def test_log_postgrest_version(defaultenv):
def test_log_query(level, defaultenv):
def test_db_error_logging_to_stderr(level, defaultenv, metapostgrest):
def test_schema_cache_query_sleep_logs(defaultenv):
def test_schema_cache_query_timings_log(level, timezone_enabled, defaultenv):
def test_empty_schema_cache_log_contains_jwt_role(defaultenv):
def test_expired_jwt_log_lacks_role(defaultenv):
def test_schema_cache_error_observation(defaultenv):
def test_invalid_rpc_method_log_contains_role(defaultenv):
def test_pgrst_log_503_client_error_to_stderr(defaultenv):
def test_termination_unix_signal_logging(defaultenv):
def test_listener_query_is_visible_in_pg_stat_activity(defaultenv):
# test_settings.py - DB Settings
def test_isolation_level(defaultenv):
def test_change_statement_timeout(defaultenv, metapostgrest):
def test_change_statement_timeout_held_connection(defaultenv, metapostgrest):
def test_first_hoisted_setting_is_applied(defaultenv):
def test_function_setting_statement_timeout_fails(defaultenv):
def test_function_setting_statement_timeout_passes(defaultenv):
def test_function_setting_work_mem(defaultenv):
def test_get_granted_superuser_setting(defaultenv):
def test_multiple_func_settings(defaultenv):
def test_role_settings(defaultenv):
def test_second_hoisted_setting_is_applied(defaultenv):
def test_statement_timeout(defaultenv, metapostgrest):
def test_succeed_w_role_having_superuser_settings(defaultenv):
# test_config.py
#
# We test config invalid values with test_cli.py and config behaviour
# in here. Maybe merge them? Not sure.
def test_allow_configs_to_be_set_to_empty(defaultenv):
def test_client_error_verbosity_config(defaultenv):
def test_db_pre_config_with_pg_reserved_words(defaultenv):
def test_db_prepared_statements_disable(defaultenv):
def test_db_prepared_statements_enable(defaultenv):
def test_schema_cache_startup_load_with_in_db_config(defaultenv, metapostgrest):
def test_fail_with_automatic_recovery_disabled_and_terminated_using_query(defaultenv):
def test_role_claim_key(roleclaim, defaultenv):
def test_jwt_aud_in_role_claim_key(jwtaudroleclaim, defaultenv):
# test_http_header.py
def test_proxy_status_header(defaultenv, metapostgrest):
def test_server_timing_transaction_duration(defaultenv, metapostgrest):
def test_vary_custom_header_set(defaultenv):
def test_vary_default_header_set(defaultenv):


```py
# test_shutdown.py or test_termination? - postgrest shutdown and recovery
def test_graceful_shutdown_waits_for_in_flight_request(defaultenv):
# I think these belong to spec tests?
def test_jwt_errors(defaultenv):
def test_iat_claim(defaultenv):
def test_jwt_cache_server_timing(defaultenv):
def test_jwt_cache_without_server_timing(defaultenv):
def test_jwt_cache_without_exp_claim(defaultenv):

Metadata

Metadata

Assignees

No one assigned

    Labels

    hygienecleanup or refactoringideaNeeds of discussion to become an enhancement, not ready for implementationtestingRelated to testing infrastructure

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions