datadog_agent_config_overlay_model/
smoke_test_support.rs

1//! Types necessary to keep the configuration smoke tests working. Intended to be transitional
2//! until we can get Saluki/ADP to stop deserializing directly from Agent configuration. At that
3//! time the smoke tests will be rendered inert and can be removed.
4use serde::{Deserialize, Serialize};
5
6/// A configuration consumer tracked by the legacy smoke-test registry.
7///
8/// Most variants name structs that consume Agent configuration directly. Sentinel variants track
9/// consumers that do not fit the legacy deserialization test model.
10#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)]
11pub enum ConfigurationStruct {
12    AggregateConfiguration,
13    DatadogEventsConfiguration,
14    DatadogLogsConfiguration,
15    DatadogServiceChecksConfiguration,
16    DogStatsDDebugLogConfiguration,
17    DogStatsDMapperConfiguration,
18    DogStatsDPrefixFilterConfiguration,
19
20    /// Keys consumed through the typed configuration translation system.
21    TypedConfigSystem,
22
23    /// Keys read via `get_typed` / `try_get_typed` rather than struct deserialization.
24    #[serde(rename = "get_typed")]
25    GetTyped,
26
27    /// Sentinel for supported keys that are being promoted during the transition to
28    /// typed-configuration access. These were missing from our inventory when config smoke
29    /// testing was introduced and for various reasons may not be legitimate targets for that
30    /// testing modality. Regardless, these fields will be part of the typed translation system
31    /// and this sentinel can be removed when our testing model moves over to that system.
32    #[serde(rename = "NO_SMOKE")]
33    NoSmoke,
34}
35
36impl ConfigurationStruct {
37    /// Apparently we travel back and forth between string constant representation and the struct
38    /// names themselves. This function recovers the string constant name for a struct.
39    pub fn as_smoke_test_const(&self) -> &'static str {
40        match self {
41            ConfigurationStruct::AggregateConfiguration => "AGGREGATE_CONFIGURATION",
42            ConfigurationStruct::DatadogEventsConfiguration => "DATADOG_EVENTS_CONFIGURATION",
43            ConfigurationStruct::DatadogLogsConfiguration => "DATADOG_LOGS_CONFIGURATION",
44            ConfigurationStruct::DatadogServiceChecksConfiguration => "DATADOG_SERVICE_CHECKS_CONFIGURATION",
45            ConfigurationStruct::DogStatsDDebugLogConfiguration => "DOGSTATSD_DEBUG_LOG_CONFIGURATION",
46            ConfigurationStruct::DogStatsDMapperConfiguration => "DOGSTATSD_MAPPER_CONFIGURATION",
47            ConfigurationStruct::DogStatsDPrefixFilterConfiguration => "DOGSTATSD_PREFIX_FILTER_CONFIGURATION",
48            ConfigurationStruct::TypedConfigSystem => "TYPED_CONFIG_SYSTEM",
49            ConfigurationStruct::GetTyped => "GET_TYPED",
50            ConfigurationStruct::NoSmoke => "NO_SMOKE",
51        }
52    }
53}