From 7035210bba709f5ddebbe5150a9dfdcd5ad4ffcd Mon Sep 17 00:00:00 2001 From: Ling Huang Date: Wed, 21 Apr 2021 14:55:57 -0400 Subject: [PATCH] Remove unnecessary test name prefix requirements and restructure testdata folder. (#63) New structure: * testdata * invalid * linux * windows * valid * linux * windows --- confgenerator/confgenerator_test.go | 33 ++++++++++--------- ...-windows-invalid_yaml => all-invalid_yaml} | 0 ...metrics-collection_interval_below_minimum} | 0 ... => metrics-collection_interval_malformed} | 0 ...xporter_id => metrics-invalid_exporter_id} | 0 ...ipeline_id => metrics-invalid_pipeline_id} | 0 ...eceiver_id => metrics-invalid_receiver_id} | 0 ...s-more_than_one_exporter_of_the_same_type} | 0 ...s-more_than_one_receiver_of_the_same_type} | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 .../golden_fluent_bit_main.conf | 0 .../golden_fluent_bit_parser.conf | 0 .../golden_otel.conf | 0 .../input.yaml | 0 37 files changed, 18 insertions(+), 15 deletions(-) rename confgenerator/testdata/invalid/windows/{all-windows-invalid_yaml => all-invalid_yaml} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-collection_interval_below_minimum => metrics-collection_interval_below_minimum} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-collection_interval_malformed => metrics-collection_interval_malformed} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-invalid_exporter_id => metrics-invalid_exporter_id} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-invalid_pipeline_id => metrics-invalid_pipeline_id} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-invalid_receiver_id => metrics-invalid_receiver_id} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-more_than_one_exporter_of_the_same_type => metrics-more_than_one_exporter_of_the_same_type} (100%) rename confgenerator/testdata/invalid/windows/{windows-metrics-more_than_one_receiver_of_the_same_type => metrics-more_than_one_receiver_of_the_same_type} (100%) rename confgenerator/testdata/valid/windows/{windows_logging-multiple_file_sources => logging-multiple_file_sources}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-multiple_file_sources => logging-multiple_file_sources}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-multiple_file_sources => logging-multiple_file_sources}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-multiple_file_sources => logging-multiple_file_sources}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_logging-no_conf => logging-no_conf}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-no_conf => logging-no_conf}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-no_conf => logging-no_conf}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_logging-no_conf => logging-no_conf}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-custom_collection_interval => metrics-custom_collection_interval}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-custom_collection_interval => metrics-custom_collection_interval}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-custom_collection_interval => metrics-custom_collection_interval}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-custom_collection_interval => metrics-custom_collection_interval}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-no_conf => metrics-no_conf}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-no_conf => metrics-no_conf}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-no_conf => metrics-no_conf}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-no_conf => metrics-no_conf}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_iis => metrics-turn_off_iis}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_iis => metrics-turn_off_iis}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_iis => metrics-turn_off_iis}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_iis => metrics-turn_off_iis}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_mssql => metrics-turn_off_mssql}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_mssql => metrics-turn_off_mssql}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_mssql => metrics-turn_off_mssql}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_metrics-turn_off_mssql => metrics-turn_off_mssql}/input.yaml (100%) rename confgenerator/testdata/valid/windows/{windows_valid_config => valid_config}/golden_fluent_bit_main.conf (100%) rename confgenerator/testdata/valid/windows/{windows_valid_config => valid_config}/golden_fluent_bit_parser.conf (100%) rename confgenerator/testdata/valid/windows/{windows_valid_config => valid_config}/golden_otel.conf (100%) rename confgenerator/testdata/valid/windows/{windows_valid_config => valid_config}/input.yaml (100%) diff --git a/confgenerator/confgenerator_test.go b/confgenerator/confgenerator_test.go index 3c89fa5354..19f65568ed 100644 --- a/confgenerator/confgenerator_test.go +++ b/confgenerator/confgenerator_test.go @@ -176,22 +176,25 @@ func TestGenerateConfigsWithInvalidInput(t *testing.T) { // Unparsable config is a success for this test return } - // TODO(lingshi): Figure out some more robust way to distinguish logging and metrics. - if strings.HasPrefix(testName, "all-") || strings.HasPrefix(testName, "logging-") { - if _, _, err := uc.GenerateFluentBitConfigs(defaultLogsDir, defaultStateDir); err == nil { - t.Errorf("test %q: GenerateFluentBitConfigs succeeded, want error. file:\n%s", testName, data) - } - } else if strings.Contains(testName, "windows") { - if _, err := uc.GenerateOtelConfig(); err == nil { - t.Errorf("test %q: GenerateOtelConfigs succeeded, want error. file:\n%s", testName, data) - } - } else if strings.HasPrefix(testName, "all-") || strings.HasPrefix(testName, "metrics-") { - if _, err := uc.GenerateCollectdConfig(defaultLogsDir); err == nil { - t.Errorf("test %q: GenerateCollectdConfig succeeded, want error. file:\n%s", testName, data) - } - } else { - t.Errorf("test %q: Unsupported test type. Must start with 'logging-' or 'metrics-'.", testName) + if err := generateConfigs(uc, defaultLogsDir, defaultStateDir); err == nil { + t.Errorf("test %q: generateConfigs succeeded, want error. input yaml:\n%s", testName, data) } }) } } + +func generateConfigs(uc UnifiedConfig, defaultLogsDir string, defaultStateDir string) (err error) { + if _, _, err := uc.GenerateFluentBitConfigs(defaultLogsDir, defaultStateDir); err != nil { + return err + } + if platform == "windows" { + if _, err := uc.GenerateOtelConfig(); err != nil { + return err + } + } else { + if _, err := uc.GenerateCollectdConfig(defaultLogsDir); err != nil { + return err + } + } + return nil +} diff --git a/confgenerator/testdata/invalid/windows/all-windows-invalid_yaml b/confgenerator/testdata/invalid/windows/all-invalid_yaml similarity index 100% rename from confgenerator/testdata/invalid/windows/all-windows-invalid_yaml rename to confgenerator/testdata/invalid/windows/all-invalid_yaml diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-collection_interval_below_minimum b/confgenerator/testdata/invalid/windows/metrics-collection_interval_below_minimum similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-collection_interval_below_minimum rename to confgenerator/testdata/invalid/windows/metrics-collection_interval_below_minimum diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-collection_interval_malformed b/confgenerator/testdata/invalid/windows/metrics-collection_interval_malformed similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-collection_interval_malformed rename to confgenerator/testdata/invalid/windows/metrics-collection_interval_malformed diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-invalid_exporter_id b/confgenerator/testdata/invalid/windows/metrics-invalid_exporter_id similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-invalid_exporter_id rename to confgenerator/testdata/invalid/windows/metrics-invalid_exporter_id diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-invalid_pipeline_id b/confgenerator/testdata/invalid/windows/metrics-invalid_pipeline_id similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-invalid_pipeline_id rename to confgenerator/testdata/invalid/windows/metrics-invalid_pipeline_id diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-invalid_receiver_id b/confgenerator/testdata/invalid/windows/metrics-invalid_receiver_id similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-invalid_receiver_id rename to confgenerator/testdata/invalid/windows/metrics-invalid_receiver_id diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-more_than_one_exporter_of_the_same_type b/confgenerator/testdata/invalid/windows/metrics-more_than_one_exporter_of_the_same_type similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-more_than_one_exporter_of_the_same_type rename to confgenerator/testdata/invalid/windows/metrics-more_than_one_exporter_of_the_same_type diff --git a/confgenerator/testdata/invalid/windows/windows-metrics-more_than_one_receiver_of_the_same_type b/confgenerator/testdata/invalid/windows/metrics-more_than_one_receiver_of_the_same_type similarity index 100% rename from confgenerator/testdata/invalid/windows/windows-metrics-more_than_one_receiver_of_the_same_type rename to confgenerator/testdata/invalid/windows/metrics-more_than_one_receiver_of_the_same_type diff --git a/confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_otel.conf b/confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/golden_otel.conf rename to confgenerator/testdata/valid/windows/logging-multiple_file_sources/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/input.yaml b/confgenerator/testdata/valid/windows/logging-multiple_file_sources/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-multiple_file_sources/input.yaml rename to confgenerator/testdata/valid/windows/logging-multiple_file_sources/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/logging-no_conf/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/logging-no_conf/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/logging-no_conf/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/logging-no_conf/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_otel.conf b/confgenerator/testdata/valid/windows/logging-no_conf/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-no_conf/golden_otel.conf rename to confgenerator/testdata/valid/windows/logging-no_conf/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_logging-no_conf/input.yaml b/confgenerator/testdata/valid/windows/logging-no_conf/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_logging-no_conf/input.yaml rename to confgenerator/testdata/valid/windows/logging-no_conf/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_otel.conf b/confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/golden_otel.conf rename to confgenerator/testdata/valid/windows/metrics-custom_collection_interval/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/input.yaml b/confgenerator/testdata/valid/windows/metrics-custom_collection_interval/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-custom_collection_interval/input.yaml rename to confgenerator/testdata/valid/windows/metrics-custom_collection_interval/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/metrics-no_conf/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/metrics-no_conf/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/metrics-no_conf/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/metrics-no_conf/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_otel.conf b/confgenerator/testdata/valid/windows/metrics-no_conf/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-no_conf/golden_otel.conf rename to confgenerator/testdata/valid/windows/metrics-no_conf/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-no_conf/input.yaml b/confgenerator/testdata/valid/windows/metrics-no_conf/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-no_conf/input.yaml rename to confgenerator/testdata/valid/windows/metrics-no_conf/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_otel.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/golden_otel.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_iis/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/input.yaml b/confgenerator/testdata/valid/windows/metrics-turn_off_iis/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_iis/input.yaml rename to confgenerator/testdata/valid/windows/metrics-turn_off_iis/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_otel.conf b/confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/golden_otel.conf rename to confgenerator/testdata/valid/windows/metrics-turn_off_mssql/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/input.yaml b/confgenerator/testdata/valid/windows/metrics-turn_off_mssql/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_metrics-turn_off_mssql/input.yaml rename to confgenerator/testdata/valid/windows/metrics-turn_off_mssql/input.yaml diff --git a/confgenerator/testdata/valid/windows/windows_valid_config/golden_fluent_bit_main.conf b/confgenerator/testdata/valid/windows/valid_config/golden_fluent_bit_main.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_valid_config/golden_fluent_bit_main.conf rename to confgenerator/testdata/valid/windows/valid_config/golden_fluent_bit_main.conf diff --git a/confgenerator/testdata/valid/windows/windows_valid_config/golden_fluent_bit_parser.conf b/confgenerator/testdata/valid/windows/valid_config/golden_fluent_bit_parser.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_valid_config/golden_fluent_bit_parser.conf rename to confgenerator/testdata/valid/windows/valid_config/golden_fluent_bit_parser.conf diff --git a/confgenerator/testdata/valid/windows/windows_valid_config/golden_otel.conf b/confgenerator/testdata/valid/windows/valid_config/golden_otel.conf similarity index 100% rename from confgenerator/testdata/valid/windows/windows_valid_config/golden_otel.conf rename to confgenerator/testdata/valid/windows/valid_config/golden_otel.conf diff --git a/confgenerator/testdata/valid/windows/windows_valid_config/input.yaml b/confgenerator/testdata/valid/windows/valid_config/input.yaml similarity index 100% rename from confgenerator/testdata/valid/windows/windows_valid_config/input.yaml rename to confgenerator/testdata/valid/windows/valid_config/input.yaml