Skip to content

Commit

Permalink
Merge pull request #5 from chatwork/fix_test
Browse files Browse the repository at this point in the history
some fix
  • Loading branch information
mumoshu authored Nov 24, 2023
2 parents 44b0b54 + 9118ae0 commit 0e9cd8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/datadog-agent/datadog-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type DatadogAgent struct {
ApiKey string
AppKey string
ClusterName string
WaitTime time.Duration
}

func NewDatadogAgent(debug bool, logger func() *logrus.Entry, chatwork *notify.Chatwork) (*DatadogAgent, error) {
Expand Down Expand Up @@ -58,6 +59,7 @@ func NewDatadogAgent(debug bool, logger func() *logrus.Entry, chatwork *notify.C
ApiKey: apiKey,
AppKey: appKey,
ClusterName: clusterName,
WaitTime: 3 * 60 * time.Second,
}, nil
}

Expand Down Expand Up @@ -102,7 +104,7 @@ func (d *DatadogAgent) checkMetrics() error {
query := fmt.Sprintf("avg:kubernetes.cpu.user.total{env:%s}", d.ClusterName)

d.Logger().Info("Waiting metrics...")
time.Sleep((60 * 3) * time.Second)
time.Sleep(d.WaitTime)

d.Logger().Infof("Querying metrics with query: %s", query)
d.Chatwork.AddMessage(fmt.Sprintf("Querying metrics with query: %s", query))
Expand Down
2 changes: 2 additions & 0 deletions cmd/datadog-agent/datadog-agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"os"
"testing"
"time"

"github.com/chatwork/kibertas/cmd"
"github.com/chatwork/kibertas/config"
Expand Down Expand Up @@ -42,6 +43,7 @@ func TestCheck(t *testing.T) {
ApiKey: "",
AppKey: "",
ClusterName: "",
WaitTime: 1 * time.Second,
}

err = datadogAgent.Check()
Expand Down

0 comments on commit 0e9cd8a

Please sign in to comment.