Skip to content

Commit

Permalink
fix: e2m test
Browse files Browse the repository at this point in the history
  • Loading branch information
celaus committed Jan 7, 2025
1 parent 5bdbde1 commit 62d22d8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 67 deletions.
7 changes: 2 additions & 5 deletions coralogix/resource_coralogix_events2metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,6 @@ func e2mSchemaV0() schema.Schema {
"metric_fields": schema.SetNestedBlock{
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"target_base_metric_name": schema.StringAttribute{
Required: true,
},
"source_field": schema.StringAttribute{
Required: true,
},
Expand Down Expand Up @@ -1137,8 +1134,8 @@ func expandE2MFields(ctx context.Context, fields types.Map) ([]*cxsdk.MetricFiel
panic(d)
}
result := make([]*cxsdk.MetricField, 0, len(fieldsMap))
for sourceFiled, metricFieldValue := range fieldsMap {
field, dgs := expandE2MField(ctx, sourceFiled, metricFieldValue)
for sourceField, metricFieldValue := range fieldsMap {
field, dgs := expandE2MField(ctx, sourceField, metricFieldValue)
if dgs.HasError() {
diags = append(diags, dgs...)
continue
Expand Down
92 changes: 30 additions & 62 deletions coralogix/resource_coralogix_events2metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,20 @@ func TestAccCoralogixResourceLogs2Metric(t *testing.T) {
resource.TestCheckResourceAttr(events2metricResourceName, "logs_query.lucene", "remote_addr_enriched:/.*/"),
resource.TestCheckResourceAttr(events2metricResourceName, "logs_query.applications.0", "nginx"),
resource.TestCheckResourceAttr(events2metricResourceName, "logs_query.severities.0", "Debug"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.source_field", "location_geopoint"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.avg.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.max.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.min.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.source_field", "duration"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.max.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.min.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.avg.enable", "true"),

resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.source_field", "duration"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.max.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.min.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.avg.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_labels.Status", "status"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_labels.Path", "http_referer"),
resource.TestCheckResourceAttr(events2metricResourceName, "permutations.limit", strconv.Itoa(events2Metric.limit)),
Expand Down Expand Up @@ -111,32 +99,20 @@ func TestAccCoralogixResourceSpans2Metric(t *testing.T) {
resource.TestCheckResourceAttr(events2metricResourceName, "spans_query.applications.0", "nginx"),
resource.TestCheckResourceAttr(events2metricResourceName, "spans_query.actions.0", "action-name"),
resource.TestCheckResourceAttr(events2metricResourceName, "spans_query.services.0", "service-name"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.source_field", "location_geopoint"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.avg.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.max.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.min.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.geo_point.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.source_field", "duration"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.max.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.min.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.method.aggregations.avg.enable", "true"),

resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.source_field", "duration"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.count.target_metric_name", "cx_count"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.count.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.histogram.target_metric_name", "cx_bucket"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.histogram.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.max.target_metric_name", "cx_max"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.max.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.min.target_metric_name", "cx_min"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.min.enable", "false"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.sum.target_metric_name", "cx_sum"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.sum.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.avg.target_metric_name", "cx_avg"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_fields.methodtwo.aggregations.avg.enable", "true"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_labels.Status", "status"),
resource.TestCheckResourceAttr(events2metricResourceName, "metric_labels.Path", "http_referer"),
resource.TestCheckResourceAttr(events2metricResourceName, "permutations.limit", strconv.Itoa(events2Metric.limit)),
Expand Down Expand Up @@ -196,12 +172,8 @@ logs_query = {
}
metric_fields = {
method = {
target_base_metric_name = "methodtwo"
methodtwo = {
source_field = "duration"
},
geo_point = {
source_field = "location_geopoint"
aggregations = {
max = {
enable = false
Expand Down Expand Up @@ -241,12 +213,8 @@ spans_query = {
}
metric_fields = {
method = {
target_base_metric_name = "methodtwo"
methodtwo = {
source_field = "duration"
},
geo_point = {
source_field = "location_geopoint"
aggregations = {
max = {
enable = false
Expand Down

0 comments on commit 62d22d8

Please sign in to comment.