-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
b276c49de282319efa7c7acceeaf4ac385cd268a
- Loading branch information
Showing
17 changed files
with
196 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## v0.5.31 - 2024-07-12 | ||
### Added | ||
* dummy generator |
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
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,56 @@ | ||
package dummy | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/yandex/pandora/core" | ||
"github.com/yandex/pandora/core/aggregator/netsample" | ||
"github.com/yandex/pandora/core/warmup" | ||
) | ||
|
||
type GunConfig struct { | ||
Sleep time.Duration `config:"sleep"` | ||
} | ||
|
||
type Gun struct { | ||
DebugLog bool | ||
Conf GunConfig | ||
Aggr core.Aggregator | ||
core.GunDeps | ||
} | ||
|
||
func DefaultGunConfig() GunConfig { | ||
return GunConfig{} | ||
} | ||
|
||
func (g *Gun) WarmUp(_ *warmup.Options) (any, error) { | ||
return nil, nil | ||
} | ||
|
||
func NewGun(conf GunConfig) *Gun { | ||
return &Gun{Conf: conf} | ||
} | ||
|
||
func (g *Gun) Bind(aggr core.Aggregator, deps core.GunDeps) error { | ||
g.Aggr = aggr | ||
g.GunDeps = deps | ||
return nil | ||
} | ||
|
||
func (g *Gun) Shoot(_ core.Ammo) { | ||
g.shoot() | ||
} | ||
|
||
func (g *Gun) shoot() { | ||
code := 0 | ||
sample := netsample.Acquire("") | ||
defer func() { | ||
sample.SetProtoCode(code) | ||
g.Aggr.Report(sample) | ||
}() | ||
|
||
time.Sleep(g.Conf.Sleep) | ||
code = 200 | ||
} | ||
|
||
var _ warmup.WarmedUp = (*Gun)(nil) |
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,11 @@ | ||
package guns | ||
|
||
import ( | ||
"github.com/spf13/afero" | ||
"github.com/yandex/pandora/components/guns/dummy" | ||
"github.com/yandex/pandora/core/register" | ||
) | ||
|
||
func Import(fs afero.Fs) { | ||
register.Gun("dummy", dummy.NewGun, dummy.DefaultGunConfig) | ||
} |
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
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
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,68 @@ | ||
package acceptance | ||
|
||
import ( | ||
"context" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/spf13/afero" | ||
"github.com/stretchr/testify/suite" | ||
"github.com/yandex/pandora/core/engine" | ||
"github.com/yandex/pandora/lib/testutil" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func TestDummyGunSuite(t *testing.T) { | ||
suite.Run(t, new(DummyGunSuite)) | ||
} | ||
|
||
type DummyGunSuite struct { | ||
suite.Suite | ||
fs afero.Fs | ||
log *zap.Logger | ||
metrics engine.Metrics | ||
} | ||
|
||
func (s *DummyGunSuite) SetupSuite() { | ||
s.fs = afero.NewOsFs() | ||
testOnce.Do(importDependencies(s.fs)) | ||
|
||
s.log = testutil.NewNullLogger() | ||
s.metrics = engine.NewMetrics("dummy_suite") | ||
} | ||
|
||
func (s *DummyGunSuite) Test_Shoot() { | ||
tests := []struct { | ||
name string | ||
filecfg string | ||
isTLS bool | ||
preStartSrv func(srv *httptest.Server) | ||
wantErrContain string | ||
wantCnt int | ||
}{ | ||
{ | ||
name: "dummy", | ||
filecfg: "testdata/dummy/dummy.yaml", | ||
wantCnt: 6, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
s.Run(tt.name, func() { | ||
|
||
conf := parseConfigFile(s.T(), tt.filecfg, "") | ||
s.Require().Equal(1, len(conf.Engine.Pools)) | ||
aggr := &aggregator{} | ||
conf.Engine.Pools[0].Aggregator = aggr | ||
pandora := engine.New(s.log, s.metrics, conf.Engine) | ||
|
||
err := pandora.Run(context.Background()) | ||
if tt.wantErrContain != "" { | ||
s.Require().Error(err) | ||
s.Require().Contains(err.Error(), tt.wantErrContain) | ||
return | ||
} | ||
s.Require().NoError(err) | ||
s.Require().Equal(int64(tt.wantCnt), int64(len(aggr.samples))) | ||
}) | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ pools: | |
rps: | ||
- times: 2 | ||
type: once | ||
- duration: 0.5s | ||
- duration: 1s | ||
ops: 4 | ||
type: const | ||
startup: | ||
|
Oops, something went wrong.