diff --git a/GNUmakefile b/GNUmakefile index 68cce89..9ecb6e6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ HOSTNAME=registry.terraform.io NAMESPACE=tsuru NAME=tsuru BINARY=terraform-provider-${NAME} -VERSION=2.9.2 +VERSION=2.12.0 UNAME_S := $(shell uname -s) UNAME_P := $(shell uname -p) diff --git a/go.mod b/go.mod index 116bd44..f7d10fb 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 github.com/labstack/echo/v4 v4.9.1 github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.4 - github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b + github.com/stretchr/testify v1.9.0 + github.com/tsuru/go-tsuruclient v0.0.0-20240409125509-22a1e08326f4 github.com/tsuru/tsuru-client v0.0.0-20240325204824-8c0dc602a5be k8s.io/apimachinery v0.26.2 ) @@ -63,12 +63,12 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.13.1 // indirect - golang.org/x/crypto v0.18.0 // indirect + golang.org/x/crypto v0.22.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/oauth2 v0.19.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 // indirect diff --git a/go.sum b/go.sum index 8b36a81..b116de8 100644 --- a/go.sum +++ b/go.sum @@ -202,12 +202,12 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa h1:JlLQP1xa13a994p/Aau2e3K9xXYaHNoNvTDVIMHSUa4= github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa/go.mod h1:UibOSvkMFKRe/eiwktAPAvQG8L+p8nYsECJvu3Dgw7I= -github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b h1:CWioMVdmtkdipWKCWVnuT+6ZqzVzB/R6hdX0SW4KJOI= -github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b/go.mod h1:qwh/KJ6ypa2GISRI79XFOHhnSjGOe1cZVPHF3nfrf18= +github.com/tsuru/go-tsuruclient v0.0.0-20240409125509-22a1e08326f4 h1:MGmG6AxKP8XRe7nQqIQR+Tsb5tCzHnYpYk0tiuXVgxY= +github.com/tsuru/go-tsuruclient v0.0.0-20240409125509-22a1e08326f4/go.mod h1:qwh/KJ6ypa2GISRI79XFOHhnSjGOe1cZVPHF3nfrf18= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 h1:1XDdWFAjIbCSG1OjN9v9KdWhuM8UtYlFcfHe/Ldkchk= github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6/go.mod h1:ztYpOhW+u1k21FEqp7nZNgpWbr0dUKok5lgGCZi+1AQ= github.com/tsuru/tsuru v0.0.0-20240325190920-410c71393b77 h1:cuWFjNLaemdQZhojqJbb/rOXO97tlcPeLAHg/x+EQGk= @@ -244,8 +244,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -267,11 +267,11 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -300,13 +300,13 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/internal/provider/resource_tsuru_app_autoscale.go b/internal/provider/resource_tsuru_app_autoscale.go index f4a9a9b..afb86d2 100644 --- a/internal/provider/resource_tsuru_app_autoscale.go +++ b/internal/provider/resource_tsuru_app_autoscale.go @@ -65,7 +65,7 @@ func resourceTsuruApplicationAutoscale() *schema.Resource { Type: schema.TypeString, Description: "CPU average, for example: 20%, mean that we trigger autoscale when the average of CPU Usage of units is 20%.", Optional: true, - AtLeastOneOf: []string{"cpu_average", "schedule"}, + AtLeastOneOf: []string{"cpu_average", "schedule", "prometheus"}, }, "schedule": { Type: schema.TypeList, @@ -91,7 +91,42 @@ func resourceTsuruApplicationAutoscale() *schema.Resource { }, }, Optional: true, - AtLeastOneOf: []string{"cpu_average", "schedule"}, + AtLeastOneOf: []string{"cpu_average", "schedule", "prometheus"}, + }, + "prometheus": { + Type: schema.TypeList, + Description: "List of Prometheus autoscale rules", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the Prometheus autoscale rule", + }, + "threshold": { + Type: schema.TypeFloat, + Required: true, + Description: "Threshold value to trigger the autoscaler", + }, + "query": { + Type: schema.TypeString, + Required: true, + Description: "Prometheus query to be used in the autoscale rule", + }, + "custom_address": { + Type: schema.TypeString, + Optional: true, + Description: "Custom Prometheus URL. If not specified, it will use the default Prometheus from the app's pool", + }, + "prometheus_address": { + Type: schema.TypeString, + Computed: true, + Description: "Custom Prometheus URL. If not specified, it will use the default Prometheus from the app's pool", + }, + }, + }, + Optional: true, + AtLeastOneOf: []string{"cpu_average", "schedule", "prometheus"}, }, }, } @@ -145,6 +180,13 @@ func resourceTsuruApplicationAutoscaleSet(ctx context.Context, d *schema.Resourc } } + if p, ok := d.GetOk("prometheus"); ok { + prometheus := prometheusFromResourceData(p) + if prometheus != nil { + autoscale.Prometheus = prometheus + } + } + err = resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { _, err = provider.TsuruClient.AppApi.AutoScaleAdd(ctx, app, autoscale) if err != nil { @@ -211,6 +253,7 @@ func resourceTsuruApplicationAutoscaleRead(ctx context.Context, d *schema.Resour } d.Set("schedule", flattenSchedules(autoscale.Schedules)) + d.Set("prometheus", flattenPrometheus(autoscale.Prometheus, d)) return nil } @@ -316,6 +359,41 @@ func schedulesFromResourceData(meta interface{}) []tsuru_client.AutoScaleSchedul return schedules } +func prometheusFromResourceData(meta interface{}) []tsuru_client.AutoScalePrometheus { + prometheusMeta := meta.([]interface{}) + + if len(prometheusMeta) == 0 { + return nil + } + + prometheus := []tsuru_client.AutoScalePrometheus{} + + for _, iface := range prometheusMeta { + prom := tsuru_client.AutoScalePrometheus{} + pm := iface.(map[string]interface{}) + + if v, ok := pm["name"]; ok { + prom.Name = v.(string) + } + + if v, ok := pm["threshold"]; ok { + prom.Threshold = v.(float64) + } + + if v, ok := pm["query"]; ok { + prom.Query = v.(string) + } + + if v, ok := pm["custom_address"]; ok { + prom.PrometheusAddress = v.(string) + } + + prometheus = append(prometheus, prom) + } + + return prometheus +} + func flattenSchedules(schedules []tsuru_client.AutoScaleSchedule) []interface{} { result := []interface{}{} @@ -330,3 +408,21 @@ func flattenSchedules(schedules []tsuru_client.AutoScaleSchedule) []interface{} return result } + +func flattenPrometheus(prometheus []tsuru_client.AutoScalePrometheus, d *schema.ResourceData) []interface{} { + result := []interface{}{} + + for i, prom := range prometheus { + customAddressStr := fmt.Sprintf("prometheus.%d.custom_address", i) + customAddress := d.Get(customAddressStr).(string) + result = append(result, map[string]interface{}{ + "name": prom.Name, + "threshold": prom.Threshold, + "query": prom.Query, + "custom_address": customAddress, + "prometheus_address": prom.PrometheusAddress, + }) + } + + return result +} diff --git a/internal/provider/resource_tsuru_app_autoscale_test.go b/internal/provider/resource_tsuru_app_autoscale_test.go index db9f96c..8b206ff 100644 --- a/internal/provider/resource_tsuru_app_autoscale_test.go +++ b/internal/provider/resource_tsuru_app_autoscale_test.go @@ -413,6 +413,174 @@ func testAccResourceTsuruAppAutoscale_schedules() string { ` } +func TestAccResourceTsuruAppAutoscaleWithPrometheus(t *testing.T) { + fakeServer := echo.New() + + iterationCount := 0 + + fakeServer.GET("/1.0/apps/:name", func(c echo.Context) error { + name := c.Param("name") + if name != "app01" { + return nil + } + + return c.JSON(http.StatusOK, &tsuru.App{ + Name: name, + Description: "my beautiful application", + TeamOwner: "myteam", + Teams: []string{ + "mysupport-team", + "mysponsors", + }, + Cluster: "my-cluster-01", + Pool: "my-pool", + Provisioner: "kubernetes", + Deploys: 2, + }) + + }) + + fakeServer.GET("/1.9/apps/:app/units/autoscale", func(c echo.Context) error { + if iterationCount == 1 { + return c.JSON(http.StatusOK, []tsuru.AutoScaleSpec{{ + Process: "web", + MinUnits: 3, + MaxUnits: 10, + AverageCPU: "800m", + Prometheus: []tsuru.AutoScalePrometheus{ + { + Name: "requests_scale", + Threshold: 2.5, + Query: "sum(rate(http_requests{app='my-app'}[5m]))", + PrometheusAddress: "http://default-prometheus.namespace.svc.cluster.local:9090", + }, + { + Name: "queue_size_scale", + Threshold: 10.0, + Query: "sum(queue_size{tsuru_app='my-app'})", + PrometheusAddress: "http://default-prometheus.namespace.svc.cluster.local:9090", + }, + }, + }}) + } else if iterationCount == 2 { + return c.JSON(http.StatusOK, []tsuru.AutoScaleSpec{{ + Process: "web", + MinUnits: 3, + MaxUnits: 10, + AverageCPU: "800m", + Prometheus: []tsuru.AutoScalePrometheus{ + { + Name: "requests_scale", + Threshold: 2.5, + Query: "sum(rate(http_requests{app='my-app'}[5m]))", + PrometheusAddress: "http://custom-prometheus.namespace.svc.cluster.local:9090", + }, + }, + }}) + } + return c.JSON(http.StatusOK, nil) + }) + + fakeServer.POST("/1.9/apps/:app/units/autoscale", func(c echo.Context) error { + autoscale := tsuru.AutoScaleSpec{} + c.Bind(&autoscale) + assert.Equal(t, "web", autoscale.Process) + iterationCount++ + return c.JSON(http.StatusOK, map[string]interface{}{"ok": "true"}) + }) + + fakeServer.DELETE("/1.9/apps/:app/units/autoscale", func(c echo.Context) error { + p := c.QueryParam("process") + assert.Equal(t, "web", p) + return c.NoContent(http.StatusNoContent) + }) + + fakeServer.HTTPErrorHandler = func(err error, c echo.Context) { + t.Errorf("methods=%s, path=%s, err=%s", c.Request().Method, c.Path(), err.Error()) + } + server := httptest.NewServer(fakeServer) + os.Setenv("TSURU_TARGET", server.URL) + + resourceName := "tsuru_app_autoscale.autoscale" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: nil, + Steps: []resource.TestStep{ + { + Config: testAccResourceTsuruAppAutoscalePrometheus(), + Check: resource.ComposeAggregateTestCheckFunc( + testAccResourceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.name", "requests_scale"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.threshold", "2.5"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.query", "sum(rate(http_requests{app='my-app'}[5m]))"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.custom_address", ""), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.prometheus_address", "http://default-prometheus.namespace.svc.cluster.local:9090"), + resource.TestCheckResourceAttr(resourceName, "prometheus.1.name", "queue_size_scale"), + resource.TestCheckResourceAttr(resourceName, "prometheus.1.threshold", "10"), + resource.TestCheckResourceAttr(resourceName, "prometheus.1.query", "sum(queue_size{tsuru_app='my-app'})"), + resource.TestCheckResourceAttr(resourceName, "prometheus.1.custom_address", ""), + resource.TestCheckResourceAttr(resourceName, "prometheus.1.prometheus_address", "http://default-prometheus.namespace.svc.cluster.local:9090"), + ), + }, + { + Config: testAccResourceTsuruAppAutoscalePrometheusWithCustomAddress(), + Check: resource.ComposeAggregateTestCheckFunc( + testAccResourceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.name", "requests_scale"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.threshold", "2.5"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.query", "sum(rate(http_requests{app='my-app'}[5m]))"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.custom_address", "http://my-prometheus.namespace.svc.cluster.local:9090"), + resource.TestCheckResourceAttr(resourceName, "prometheus.0.prometheus_address", "http://custom-prometheus.namespace.svc.cluster.local:9090"), + ), + }, + }, + }) +} + +func testAccResourceTsuruAppAutoscalePrometheus() string { + return ` + resource "tsuru_app_autoscale" "autoscale" { + app = "app01" + process = "web" + min_units = 3 + max_units = 10 + cpu_average = "80%" + + prometheus { + name = "requests_scale" + threshold = 2.5 + query = "sum(rate(http_requests{app='my-app'}[5m]))" + } + + prometheus { + name = "queue_size_scale" + threshold = 10 + query = "sum(queue_size{tsuru_app='my-app'})" + } + } +` +} + +func testAccResourceTsuruAppAutoscalePrometheusWithCustomAddress() string { + return ` + resource "tsuru_app_autoscale" "autoscale" { + app = "app01" + process = "web" + min_units = 3 + max_units = 10 + cpu_average = "80%" + + prometheus { + name = "requests_scale" + threshold = 2.5 + query = "sum(rate(http_requests{app='my-app'}[5m]))" + custom_address = "http://my-prometheus.namespace.svc.cluster.local:9090" + } + } +` +} + func TestAccResourceTsuruAppAutoscaleWithoutCPU(t *testing.T) { fakeServer := echo.New() @@ -530,7 +698,7 @@ func testAccResourceTsuruAppAutoscale_withoutCpu() string { ` } -func TestAccTsuruAutoscaleSetShouldErrorWithoutScheduleAndCPU(t *testing.T) { +func TestAccTsuruAutoscaleSetShouldErrorWithoutCPUOrScheduleOrPrometheus(t *testing.T) { resource.Test(t, resource.TestCase{ ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ @@ -542,7 +710,7 @@ func TestAccTsuruAutoscaleSetShouldErrorWithoutScheduleAndCPU(t *testing.T) { min_units = 3 max_units = 10 }`, - ExpectError: regexp.MustCompile("one of `cpu_average,schedule` must be specified"), + ExpectError: regexp.MustCompile("one of `cpu_average,prometheus,schedule` must be specified"), }, }, })