@@ -104,6 +104,25 @@ var (
104104 "parser" : acctest.RepresentationGroup {RepType : acctest .Required , Group : LoggingUnifiedAgentConfigurationServiceConfigurationSourcesParserRepresentation },
105105 //"channels": acctest.Representation{RepType: acctest.Required, Create: []string{`Security`}, Update: []string{`Security`, `Application`}},
106106 }
107+
108+ // Add new test configs here
109+ // CRI parser configs
110+ LoggingUnifiedAgentConfigurationServiceConfigurationSourcesCriParserNestedParserRepresentation = map [string ]interface {}{
111+ "time_format" : acctest.Representation {RepType : acctest .Optional , Create : `%Y-%m-%dT%H:%M:%S.%L%z` , Update : `%Y-%m-%d %H:%M:%S.%L%z` },
112+ "field_time_key" : acctest.Representation {RepType : acctest .Optional , Create : `time` , Update : `time1` },
113+ "is_keep_time_key" : acctest.Representation {RepType : acctest .Optional , Create : `true` , Update : `false` },
114+ }
115+
116+ LoggingUnifiedAgentConfigurationServiceConfigurationSourcesCriParserRepresentation = map [string ]interface {}{
117+ "parser_type" : acctest.Representation {RepType : acctest .Required , Create : `CRI` },
118+ "is_merge_cri_fields" : acctest.Representation {RepType : acctest .Optional , Create : `true` , Update : `false` },
119+ "nested_parser" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : LoggingUnifiedAgentConfigurationServiceConfigurationSourcesCriParserNestedParserRepresentation },
120+ }
121+
122+ LoggingUnifiedAgentConfigurationCriRepresentation = acctest .GetUpdatedRepresentationCopy (
123+ "service_configuration.sources.parser" ,
124+ acctest.RepresentationGroup {RepType : acctest .Required , Group : LoggingUnifiedAgentConfigurationServiceConfigurationSourcesCriParserRepresentation },
125+ LoggingUnifiedAgentConfigurationRepresentation )
107126)
108127
109128// issue-routing-tag: logging/default
@@ -129,6 +148,90 @@ func TestLoggingUnifiedAgentConfigurationResource_basic(t *testing.T) {
129148 acctest .GenerateResourceFromRepresentationMap ("oci_logging_unified_agent_configuration" , "test_unified_agent_configuration" , acctest .Optional , acctest .Create , LoggingUnifiedAgentConfigurationRepresentation ), "logging" , "unifiedAgentConfiguration" , t )
130149
131150 acctest .ResourceTest (t , testAccCheckLoggingUnifiedAgentConfigurationDestroy , []resource.TestStep {
151+
152+ // Add new tests here
153+ // CRI parser test required
154+ {
155+ Config : config + compartmentIdVariableStr + LoggingUnifiedAgentConfigurationResourceDependencies +
156+ acctest .GenerateResourceFromRepresentationMap ("oci_logging_unified_agent_configuration" , "test_unified_agent_configuration" , acctest .Required , acctest .Create , LoggingUnifiedAgentConfigurationCriRepresentation ),
157+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
158+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
159+ resource .TestCheckResourceAttr (resourceName , "is_enabled" , "true" ),
160+ resource .TestCheckResourceAttr (resourceName , "service_configuration.#" , "1" ),
161+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.configuration_type" , "LOGGING" ),
162+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.destination.#" , "1" ),
163+ resource .TestCheckResourceAttrSet (resourceName , "service_configuration.0.destination.0.log_object_id" ),
164+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.#" , "1" ),
165+ //resource.TestCheckResourceAttr(resourceName, "service_configuration.0.sources.0.channels.#", "1"),
166+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.name" , "name" ),
167+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.paths.#" , "1" ),
168+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.source_type" , "LOG_TAIL" ),
169+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.parser_type" , "CRI" ),
170+
171+ func (s * terraform.State ) (err error ) {
172+ _ , err = acctest .FromInstanceState (s , resourceName , "id" )
173+ return err
174+ },
175+ ),
176+ },
177+ // CRI parser test optional
178+ {
179+ Config : config + compartmentIdVariableStr + LoggingUnifiedAgentConfigurationResourceDependencies +
180+ acctest .GenerateResourceFromRepresentationMap ("oci_logging_unified_agent_configuration" , "test_unified_agent_configuration" , acctest .Optional , acctest .Create , LoggingUnifiedAgentConfigurationCriRepresentation ),
181+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
182+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
183+ resource .TestCheckResourceAttr (resourceName , "is_enabled" , "true" ),
184+ resource .TestCheckResourceAttr (resourceName , "service_configuration.#" , "1" ),
185+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.configuration_type" , "LOGGING" ),
186+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.destination.#" , "1" ),
187+ resource .TestCheckResourceAttrSet (resourceName , "service_configuration.0.destination.0.log_object_id" ),
188+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.#" , "1" ),
189+ //resource.TestCheckResourceAttr(resourceName, "service_configuration.0.sources.0.channels.#", "1"),
190+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.name" , "name" ),
191+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.paths.#" , "1" ),
192+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.source_type" , "LOG_TAIL" ),
193+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.parser_type" , "CRI" ),
194+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.is_merge_cri_fields" , "true" ),
195+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.time_format" , "%Y-%m-%dT%H:%M:%S.%L%z" ),
196+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.field_time_key" , "time" ),
197+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.is_keep_time_key" , "true" ),
198+
199+ func (s * terraform.State ) (err error ) {
200+ _ , err = acctest .FromInstanceState (s , resourceName , "id" )
201+ return err
202+ },
203+ ),
204+ },
205+ // CRI parser test optional update
206+ {
207+ Config : config + compartmentIdVariableStr + LoggingUnifiedAgentConfigurationResourceDependencies +
208+ acctest .GenerateResourceFromRepresentationMap ("oci_logging_unified_agent_configuration" , "test_unified_agent_configuration" , acctest .Optional , acctest .Update , LoggingUnifiedAgentConfigurationCriRepresentation ),
209+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
210+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
211+ resource .TestCheckResourceAttr (resourceName , "is_enabled" , "false" ),
212+ resource .TestCheckResourceAttr (resourceName , "service_configuration.#" , "1" ),
213+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.configuration_type" , "LOGGING" ),
214+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.destination.#" , "1" ),
215+ resource .TestCheckResourceAttrSet (resourceName , "service_configuration.0.destination.0.log_object_id" ),
216+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.#" , "1" ),
217+ //resource.TestCheckResourceAttr(resourceName, "service_configuration.0.sources.0.channels.#", "1"),
218+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.name" , "name" ),
219+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.paths.#" , "1" ),
220+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.source_type" , "LOG_TAIL" ),
221+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.parser_type" , "CRI" ),
222+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.is_merge_cri_fields" , "false" ),
223+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.time_format" , "%Y-%m-%d %H:%M:%S.%L%z" ),
224+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.field_time_key" , "time1" ),
225+ resource .TestCheckResourceAttr (resourceName , "service_configuration.0.sources.0.parser.0.nested_parser.0.is_keep_time_key" , "false" ),
226+
227+ func (s * terraform.State ) (err error ) {
228+ _ , err = acctest .FromInstanceState (s , resourceName , "id" )
229+ return err
230+ },
231+ ),
232+ },
233+
234+ // Don't change below tests
132235 // 0. verify Create
133236 {
134237 Config : config + compartmentIdVariableStr + LoggingUnifiedAgentConfigurationResourceDependencies +
0 commit comments