Skip to content

Commit

Permalink
feat: add metrics to knuu (#3210)
Browse files Browse the repository at this point in the history
This PR adds metrics to knuu tests which are published alongside the
logs
  • Loading branch information
cmwaters authored Mar 26, 2024
1 parent deefb54 commit 14ad038
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 68 deletions.
11 changes: 5 additions & 6 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX
cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY=
cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw=
cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5fk=
cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5fk=
cloud.google.com/go/accessapproval v1.7.1 h1:/5YjNhR6lzCvmJZAnByYkfEgWjfAKwYP6nkuTk6nKFE=
cloud.google.com/go/accessapproval v1.7.1/go.mod h1:JYczztsHRMK7NTXb6Xw+dwbs/WnOJxbo/2mTI+Kgg68=
cloud.google.com/go/accessapproval v1.7.4/go.mod h1:/aTEh45LzplQgFYdQdwPMR9YdX0UlhBmvB84uAmQKUc=
Expand Down Expand Up @@ -108,7 +107,6 @@ cloud.google.com/go/compute v1.19.3/go.mod h1:qxvISKp/gYnXkSAD1ppcSOveRAmzxicEv/
cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3Xp1ixncW78=
cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM=
Expand Down Expand Up @@ -735,7 +733,6 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs=
github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs=
github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA=
Expand Down Expand Up @@ -988,7 +985,6 @@ github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:r
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
Expand Down Expand Up @@ -1093,6 +1089,7 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
Expand All @@ -1106,13 +1103,13 @@ golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I=
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
Expand Down Expand Up @@ -1150,8 +1147,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
Expand Down Expand Up @@ -1187,6 +1184,7 @@ golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750=
google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Expand Down Expand Up @@ -1233,6 +1231,7 @@ google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
Expand Down
77 changes: 25 additions & 52 deletions test/e2e/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (
)

const (
rpcPort = 26657
p2pPort = 26656
grpcPort = 9090
metricsPort = 26660
dockerSrcURL = "ghcr.io/celestiaorg/celestia-app"
secp256k1Type = "secp256k1"
ed25519Type = "ed25519"
remoteRootDir = "/home/celestia/.celestia-app"
rpcPort = 26657
p2pPort = 26656
grpcPort = 9090
prometheusPort = 26660
dockerSrcURL = "ghcr.io/celestiaorg/celestia-app"
secp256k1Type = "secp256k1"
ed25519Type = "ed25519"
remoteRootDir = "/home/celestia/.celestia-app"
)

type Node struct {
Expand All @@ -47,6 +47,7 @@ func NewNode(
peers []string,
signerKey, networkKey, accountKey crypto.PrivKey,
upgradeHeight int64,
grafana *GrafanaInfo,
) (*Node, error) {
instance, err := knuu.NewInstance(name)
if err != nil {
Expand All @@ -65,8 +66,20 @@ func NewNode(
if err := instance.AddPortTCP(grpcPort); err != nil {
return nil, err
}
if err := instance.AddPortUDP(metricsPort); err != nil {
return nil, err
if grafana != nil {
// add support for metrics
if err := instance.SetPrometheusEndpoint(prometheusPort, fmt.Sprintf("knuu-%s", knuu.Identifier()), "1m"); err != nil {
return nil, fmt.Errorf("setting prometheus endpoint: %w", err)
}
if err := instance.SetJaegerEndpoint(14250, 6831, 14268); err != nil {
return nil, fmt.Errorf("error setting jaeger endpoint: %v", err)
}
if err := instance.SetOtlpExporter(grafana.Endpoint, grafana.Username, grafana.Token); err != nil {
return nil, fmt.Errorf("error setting otlp exporter: %v", err)
}
if err := instance.SetJaegerExporter("jaeger-collector.jaeger-cluster.svc.cluster.local:14250"); err != nil {
return nil, fmt.Errorf("error setting jaeger exporter: %v", err)
}
}
err = instance.SetMemory("200Mi", "200Mi")
if err != nil {
Expand Down Expand Up @@ -166,48 +179,8 @@ func (n *Node) Init(genesis types.GenesisDoc, peers []string) error {
return fmt.Errorf("writing address book: %w", err)
}

_, err = n.Instance.ExecuteCommand(fmt.Sprintf("mkdir -p %s/config", remoteRootDir))
if err != nil {
return fmt.Errorf("creating config directory: %w", err)
}
_, err = n.Instance.ExecuteCommand(fmt.Sprintf("mkdir -p %s/data", remoteRootDir))
if err != nil {
return fmt.Errorf("creating data directory: %w", err)
}

err = n.Instance.AddFile(configFilePath, filepath.Join(remoteRootDir, "config", "config.toml"), "10001:10001")
if err != nil {
return fmt.Errorf("adding config file: %w", err)
}

err = n.Instance.AddFile(genesisFilePath, filepath.Join(remoteRootDir, "config", "genesis.json"), "10001:10001")
if err != nil {
return fmt.Errorf("adding genesis file: %w", err)
}

err = n.Instance.AddFile(appConfigFilePath, filepath.Join(remoteRootDir, "config", "app.toml"), "10001:10001")
if err != nil {
return fmt.Errorf("adding app config file: %w", err)
}

err = n.Instance.AddFile(pvKeyPath, filepath.Join(remoteRootDir, "config", "priv_validator_key.json"), "10001:10001")
if err != nil {
return fmt.Errorf("adding priv_validator_key file: %w", err)
}

err = n.Instance.AddFile(pvStatePath, filepath.Join(remoteRootDir, "data", "priv_validator_state.json"), "10001:10001")
if err != nil {
return fmt.Errorf("adding priv_validator_state file: %w", err)
}

err = n.Instance.AddFile(nodeKeyFilePath, filepath.Join(remoteRootDir, "config", "node_key.json"), "10001:10001")
if err != nil {
return fmt.Errorf("adding node_key file: %w", err)
}

err = n.Instance.AddFile(addrBookFile, filepath.Join(remoteRootDir, "config", "addrbook.json"), "10001:10001")
if err != nil {
return fmt.Errorf("adding addrbook file: %w", err)
if err := n.Instance.AddFolder(nodeDir, remoteRootDir, "10001:10001"); err != nil {
return fmt.Errorf("copying over node %s directory: %w", n.Name, err)
}

return n.Instance.Commit()
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ You can optionally set a global timeout using `KNUU_TIMEOUT` (default is 60m).
## Observation

Logs of each of the nodes are posted to Grafana and can be accessed through Celestia's dashboard (using the `test` namespace).

### Metrics

To view the metrics from the testnet, you should set the `GRAFANA_ENDPOINT`, `GRAFANA_USERNAME`, and `GRAFANA_TOKEN` environment variables. This uses Prometheus alongside the Jaeger and Otlp Exporter.
2 changes: 1 addition & 1 deletion test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func MakeGenesis(nodes []*Node, accounts []*Account) (types.GenesisDoc, error) {

// Validator set and app hash are set in InitChain
return types.GenesisDoc{
ChainID: "testnet",
ChainID: "test", // this should match the namespace
GenesisTime: time.Now().UTC(),
ConsensusParams: app.DefaultConsensusParams(),
AppState: appState,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestE2ESimple(t *testing.T) {
}
t.Log("Running simple e2e test", "version", latestVersion)

testnet, err := New(t.Name(), seed)
testnet, err := New(t.Name(), seed, GetGrafanaInfoFromEnvVar())
require.NoError(t, err)
t.Cleanup(testnet.Cleanup)
require.NoError(t, testnet.CreateGenesisNodes(4, latestVersion, 10000000, 0))
Expand Down
20 changes: 14 additions & 6 deletions test/e2e/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ type Testnet struct {
nodes []*Node
genesisAccounts []*Account
keygen *keyGenerator
grafana *GrafanaInfo
}

func New(name string, seed int64) (*Testnet, error) {
func New(name string, seed int64, grafana *GrafanaInfo) (*Testnet, error) {
identifier := fmt.Sprintf("%s_%s", name, time.Now().Format("20060102_150405"))
if err := knuu.InitializeWithIdentifier(identifier); err != nil {
return nil, err
Expand All @@ -31,14 +32,15 @@ func New(name string, seed int64) (*Testnet, error) {
nodes: make([]*Node, 0),
genesisAccounts: make([]*Account, 0),
keygen: newKeyGenerator(seed),
grafana: grafana,
}, nil
}

func (t *Testnet) CreateGenesisNode(version string, selfDelegation, upgradeHeight int64) error {
signerKey := t.keygen.Generate(ed25519Type)
networkKey := t.keygen.Generate(ed25519Type)
accountKey := t.keygen.Generate(secp256k1Type)
node, err := NewNode(fmt.Sprintf("val%d", len(t.nodes)), version, 0, selfDelegation, nil, signerKey, networkKey, accountKey, upgradeHeight)
node, err := NewNode(fmt.Sprintf("val%d", len(t.nodes)), version, 0, selfDelegation, nil, signerKey, networkKey, accountKey, upgradeHeight, t.grafana)
if err != nil {
return err
}
Expand All @@ -59,7 +61,7 @@ func (t *Testnet) CreateNode(version string, startHeight, upgradeHeight int64) e
signerKey := t.keygen.Generate(ed25519Type)
networkKey := t.keygen.Generate(ed25519Type)
accountKey := t.keygen.Generate(secp256k1Type)
node, err := NewNode(fmt.Sprintf("val%d", len(t.nodes)), version, startHeight, 0, nil, signerKey, networkKey, accountKey, upgradeHeight)
node, err := NewNode(fmt.Sprintf("val%d", len(t.nodes)), version, startHeight, 0, nil, signerKey, networkKey, accountKey, upgradeHeight, t.grafana)
if err != nil {
return err
}
Expand Down Expand Up @@ -172,10 +174,16 @@ func (t *Testnet) Cleanup() {
log.Err(err).Msg(fmt.Sprintf("node %s failed to stop", node.Name))
continue
}
if err := node.Instance.WaitInstanceIsStopped(); err != nil {
log.Err(err).Msg(fmt.Sprintf("node %s failed to stop", node.Name))
continue
}
}
err := node.Instance.Destroy()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("node %s failed to cleanup", node.Name))
if node.Instance.IsInState(knuu.Started, knuu.Stopped) {
err := node.Instance.Destroy()
if err != nil {
log.Err(err).Msg(fmt.Sprintf("node %s failed to cleanup", node.Name))
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestMinorVersionCompatibility(t *testing.T) {
r := rand.New(rand.NewSource(seed))
t.Log("Running minor version compatibility test", "versions", versions)

testnet, err := New(t.Name(), seed)
testnet, err := New(t.Name(), seed, GetGrafanaInfoFromEnvVar())
require.NoError(t, err)
t.Cleanup(testnet.Cleanup)

Expand Down Expand Up @@ -152,7 +152,7 @@ func TestMajorUpgradeToV2(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testnet, err := New(t.Name(), seed)
testnet, err := New(t.Name(), seed, GetGrafanaInfoFromEnvVar())
require.NoError(t, err)
t.Cleanup(testnet.Cleanup)

Expand Down
21 changes: 21 additions & 0 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e
import (
"io"
"math/rand"
"os"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
Expand Down Expand Up @@ -35,3 +36,23 @@ func (g *keyGenerator) Generate(keyType string) crypto.PrivKey {
panic("KeyType not supported") // should not make it this far
}
}

type GrafanaInfo struct {
Endpoint string
Username string
Token string
}

func GetGrafanaInfoFromEnvVar() *GrafanaInfo {
if os.Getenv("GRAFANA_ENDPOINT") == "" ||
os.Getenv("GRAFANA_USERNAME") == "" ||
os.Getenv("GRAFANA_TOKEN") == "" {
return nil
}

return &GrafanaInfo{
Endpoint: os.Getenv("GRAFANA_ENDPOINT"),
Username: os.Getenv("GRAFANA_USERNAME"),
Token: os.Getenv("GRAFANA_TOKEN"),
}
}

0 comments on commit 14ad038

Please sign in to comment.