-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81f5d0b
commit 556d9ae
Showing
3 changed files
with
155 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
main "github.com/superfly/fly-autoscaler/cmd/fly-autoscaler" | ||
) | ||
|
||
func TestConfig_Parse(t *testing.T) { | ||
var config main.Config | ||
if err := main.ParseConfigFromFile("../../etc/fly-autoscaler.yml", &config); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if got, want := config.AppName, "TARGET_APP_NAME"; got != want { | ||
t.Fatalf("AppName=%v, want %v", got, want) | ||
} | ||
if got, want := config.Expr, "ceil(queue_depth / 10)"; got != want { | ||
t.Fatalf("Expr=%v, want %v", got, want) | ||
} | ||
if got, want := config.Interval, 15*time.Second; got != want { | ||
t.Fatalf("Interval=%v, want %v", got, want) | ||
} | ||
if got, want := config.APIToken, "FlyV1 ..."; got != want { | ||
t.Fatalf("APIToken=%v, want %v", got, want) | ||
} | ||
if got, want := config.Verbose, false; got != want { | ||
t.Fatalf("Verbose=%v, want %v", got, want) | ||
} | ||
|
||
mc := config.MetricCollectors[0] | ||
if got, want := mc.Type, "prometheus"; got != want { | ||
t.Fatalf("MC[0].Type=%v, want %v", got, want) | ||
} | ||
if got, want := mc.MetricName, "queue_depth"; got != want { | ||
t.Fatalf("MC[0].MetricName=%v, want %v", got, want) | ||
} | ||
if got, want := mc.Address, "https://api.fly.io/prometheus/MY_ORG"; got != want { | ||
t.Fatalf("MC[0].Address=%v, want %v", got, want) | ||
} | ||
if got, want := mc.Query, "sum(queue_depth)"; got != want { | ||
t.Fatalf("MC[0].Query=%v, want %v", got, want) | ||
} | ||
if got, want := mc.Token, "FlyV1 ..."; got != want { | ||
t.Fatalf("MC[0].Token=%v, want %v", got, want) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# The name of the target app that you want to scale. | ||
app-name: "TARGET_APP_NAME" | ||
|
||
# An expression to calculate the number of machines of the target app that | ||
# should be in a "started" state. Should return a number which will be rounded. | ||
# | ||
# This uses the Expr language to define expressions: https://expr-lang.org/ | ||
expr: "ceil(queue_depth / 10)" | ||
|
||
# The frequency that the reconciliation loop will be run. | ||
interval: "15s" | ||
|
||
# A Fly.io auth token that has permission to start machines for the target app. | ||
# This is typically set via the FAS_API_TOKEN environment variable. | ||
api-token: "FlyV1 ..." | ||
|
||
# If true, enables verbose debugging logging. | ||
verbose: false | ||
|
||
# Metric collectors fetch the current metrics when a reconciliation is performed. | ||
# | ||
# They store the current value locally with a given metric name so that the | ||
# expression can be used to calculate the machine count. | ||
metric-collectors: | ||
- type: "prometheus" | ||
metric-name: "queue_depth" | ||
address: "https://api.fly.io/prometheus/MY_ORG" | ||
query: "sum(queue_depth)" | ||
token: "FlyV1 ..." |