def test_content_with_exact_len_not_trimmed():
    message = "WALTHAM, Mass.--(BUSINESS WIRE)-- Software intelligence company Dynatrace (NYSE: DT)"
    content_length_limit_backup = logs_ingest.main.content_length_limit

    # given
    log_entry = create_log_entry(message)
    logs_ingest.main.content_length_limit = len(json.dumps(log_entry))

    # when
    try:
        actual_output = parse_record(
            log_entry, SelfMonitoring(execution_time=datetime.utcnow()))
    finally:
        # restore original value
        logs_ingest.main.content_length_limit = content_length_limit_backup

    # then
    expected_output = {
        "cloud.provider":
        "Azure",
        "severity":
        "INFO",
        "content":
        '{"content": "WALTHAM, Mass.--(BUSINESS WIRE)-- Software intelligence company Dynatrace (NYSE: DT)"}'
    }
    assert actual_output == expected_output
def test_content_trimmed():
    content_length_limit = 100
    content_length_limit_backup = logs_ingest.main.content_length_limit

    # given
    log_entry = create_log_entry(log_message)
    logs_ingest.main.content_length_limit = content_length_limit

    # when
    try:
        actual_output = parse_record(
            log_entry, SelfMonitoring(execution_time=datetime.utcnow()))
    finally:
        # restore original value
        logs_ingest.main.content_length_limit = content_length_limit_backup

    # then
    expected_content = "{\"content\": \"WALTHAM, Mass.--(BUSINESS WIRE)-- Software intelligence company Dynatrace (N[TRUNCATED]"
    assert len(actual_output["content"]) == content_length_limit
    assert actual_output["content"] == expected_content
def test_log_forwarder_setup():
    cloud_log_forwarder_backup = logs_ingest.main.cloud_log_forwarder
    logs_ingest.main.cloud_log_forwarder = "MyLogForwarderSetup"

    # given
    test_record = {
        "cloud.provider":
        "Azure",
        "severity":
        "INFO",
        "content":
        '{"content": "WALTHAM, Mass.--(BUSINESS WIRE)-- Software intelligence company Dynatrace (NYSE: DT)"}'
    }

    # when
    try:
        actual_output = parse_record(
            test_record, SelfMonitoring(execution_time=datetime.utcnow()))
    finally:
        logs_ingest.main.cloud_log_forwarder = cloud_log_forwarder_backup

    # then
    assert actual_output['cloud.log_forwarder'] == "MyLogForwarderSetup"
def test_automatic_tuning_log(self_monitoring):
    actual_output = parse_record(automatic_tuning_log, self_monitoring)
    assert actual_output == automatic_tuning_log_expected_output
Exemple #5
0
def test_table_access_log(self_monitoring):
    actual_output = parse_record(table_access_log, self_monitoring)
    assert actual_output == table_access_log_expected_output
Exemple #6
0
def test_slow_log(self_monitoring):
    actual_output = parse_record(slow_log, self_monitoring)
    assert actual_output == slow_log_expected_output
def test_default():
    actual_output = main.parse_record(
        record, SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == expected_output
Exemple #8
0
def test_database_wait_statistics_log(self_monitoring):
    actual_output = parse_record(database_wait_statistics_log, self_monitoring)
    assert actual_output == database_wait_statistics_log_expected_output
Exemple #9
0
def test_query_store_runtime_statistics_log(self_monitoring):
    actual_output = parse_record(query_store_runtime_statistics_log,
                                 self_monitoring)
    assert actual_output == query_store_runtime_statistics_log_expected_output
def test_policy_log(self_monitoring):
    actual_output = parse_record(policy_record, self_monitoring)
    assert actual_output == policy_expected_output
def test_administrative_log(self_monitoring):
    actual_output = parse_record(administrative_record, self_monitoring)
    assert actual_output == administrative_expected_output
def test_activity_log(self_monitoring):
    actual_output = parse_record(activity_record, self_monitoring)
    assert actual_output == activity_expected_output
Exemple #13
0
def test_kube_controller_manager():
    output = parse_record(kube_controller_manager_record,
                          SelfMonitoring(execution_time=datetime.utcnow()))
    assert output == kube_controller_manager_expected_output
Exemple #14
0
def test_kube_audit():
    output = parse_record(kube_audit_record,
                          SelfMonitoring(execution_time=datetime.utcnow()))
    assert output == kube_audit_expected_output
Exemple #15
0
def test_alert_log(self_monitoring):
    actual_output = parse_record(alert_record, self_monitoring)
    assert actual_output == alert_expected_output
def test_timeouts_log(self_monitoring):
    actual_output = parse_record(timeouts_log, self_monitoring)
    assert actual_output == timeouts_log_expected_output
def test_deadlocks_log(self_monitoring):
    actual_output = parse_record(deadlocks_log, self_monitoring)
    assert actual_output == deadlocks_log_expected_output
def test_resource_health_log(self_monitoring):
    actual_output = parse_record(resource_health_record, self_monitoring)
    assert actual_output == resource_health_expected_output
Exemple #19
0
def test_errors_log(self_monitoring):
    actual_output = parse_record(errors_log, self_monitoring)
    assert actual_output == errors_log_expected_output
Exemple #20
0
def test_event_hub_namespace():
    actual_output = parse_record(
        record, SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == expected_output
Exemple #21
0
def test_resource_usage_stats_log(self_monitoring):
    actual_output = parse_record(resource_usage_stats_log, self_monitoring)
    assert actual_output == resource_usage_stats_log_expected_output
Exemple #22
0
def test_api_management_service():
    actual_output = parse_record(
        record, SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == expected_output
def test_trimming_attribute_values(monkeypatch: MonkeyPatchFixture):
    monkeypatch.setattr(main, 'attribute_value_length_limit', 4)
    actual_output = main.parse_record(
        record, SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == expected_output_attribute_values_trimmed
Exemple #24
0
def test_function_app_logs():
    actual_output = parse_record(
        function_app_logs_record,
        SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == function_app_logs_expected_output
Exemple #25
0
def test_general_log(self_monitoring):
    actual_output = parse_record(general_log, self_monitoring)
    assert actual_output == general_log_expected_output
Exemple #26
0
def test_not_known_category():
    actual_output = parse_record(
        not_known_category_record,
        SelfMonitoring(execution_time=datetime.utcnow()))
    assert actual_output == not_known_category_expected_output
Exemple #27
0
def test_connection_log(self_monitoring):
    actual_output = parse_record(connection_log_record, self_monitoring)
    assert actual_output == connection_log_expected_output
def test_postgresql_log(self_monitoring):
    actual_output = parse_record(postgresql_log, self_monitoring)
    assert actual_output == postgresql_log_expected_output