Skip to content

Commit

Permalink
Merge pull request #177 from yandex/dev
Browse files Browse the repository at this point in the history
v0.5.18
  • Loading branch information
oke11o authored Jan 15, 2024
2 parents dda167d + bf8e7b3 commit 33abe68
Show file tree
Hide file tree
Showing 83 changed files with 3,087 additions and 2,736 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
release:
types: [created]
types: [ created ]

permissions:
contents: write
Expand All @@ -14,8 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
arch: [amd64]
os: [ ubuntu-latest, macOS-latest ]
arch: [ amd64 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand All @@ -24,14 +24,16 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
go-version: 1.21.x
cache: true

- name: Test
run: go test -race -covermode atomic ./...

- name: Set GITHUB_ENV
run: |
stripped_tag="${{ github.event.release.tag_name }}"
echo "STRIPPED_TAG=${stripped_tag:1}" >> "$GITHUB_ENV"
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "GOOS=linux" >> $GITHUB_ENV
else
Expand All @@ -42,9 +44,9 @@ jobs:
run: |
export GOARCH=${{ matrix.arch }}
export CGO_ENABLED=0
go build -o pandora_${{ github.event.release.tag_name }}_${GOOS}_${{ matrix.arch }}
go build -o pandora_${STRIPPED_TAG}_${GOOS}_${{ matrix.arch }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: pandora_${{ github.event.release.tag_name }}_${{ env.GOOS }}_${{ matrix.arch }}
files: pandora_${{ env.STRIPPED_TAG }}_${{ env.GOOS }}_${{ matrix.arch }}
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev

jobs:
run-unit-tests:
Expand All @@ -17,7 +19,6 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.20.x, 1.21.x]
os: [ubuntu, macOS]
env:
OS: ${{ matrix.os }}-latest
Expand All @@ -30,7 +31,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
go-version: 1.21.x
cache: true

- name: Test
Expand Down
90 changes: 51 additions & 39 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@
"components/guns/http_scenario/gun.go":"load/projects/pandora/components/guns/http_scenario/gun.go",
"components/guns/http_scenario/gun_test.go":"load/projects/pandora/components/guns/http_scenario/gun_test.go",
"components/guns/http_scenario/import.go":"load/projects/pandora/components/guns/http_scenario/import.go",
"components/guns/http_scenario/mock_ammo_test.go":"load/projects/pandora/components/guns/http_scenario/mock_ammo_test.go",
"components/guns/http_scenario/mock_client_test.go":"load/projects/pandora/components/guns/http_scenario/mock_client_test.go",
"components/guns/http_scenario/mock_postprocessor_test.go":"load/projects/pandora/components/guns/http_scenario/mock_postprocessor_test.go",
"components/guns/http_scenario/mock_preprocessor_test.go":"load/projects/pandora/components/guns/http_scenario/mock_preprocessor_test.go",
"components/guns/http_scenario/mock_step_test.go":"load/projects/pandora/components/guns/http_scenario/mock_step_test.go",
"components/guns/http_scenario/mock_templater_test.go":"load/projects/pandora/components/guns/http_scenario/mock_templater_test.go",
"components/guns/http_scenario/new.go":"load/projects/pandora/components/guns/http_scenario/new.go",
"components/guns/http_scenario/templater.go":"load/projects/pandora/components/guns/http_scenario/templater.go",
"components/phttp/import/import.go":"load/projects/pandora/components/phttp/import/import.go",
Expand Down Expand Up @@ -79,39 +74,45 @@
"components/providers/http/testdata/ammo.stpd":"load/projects/pandora/components/providers/http/testdata/ammo.stpd",
"components/providers/http/util/request.go":"load/projects/pandora/components/providers/http/util/request.go",
"components/providers/http/util/request_test.go":"load/projects/pandora/components/providers/http/util/request_test.go",
"components/providers/http_scenario/ammo.go":"load/projects/pandora/components/providers/http_scenario/ammo.go",
"components/providers/http_scenario/ammo_config.go":"load/projects/pandora/components/providers/http_scenario/ammo_config.go",
"components/providers/http_scenario/ammo_hcl.go":"load/projects/pandora/components/providers/http_scenario/ammo_hcl.go",
"components/providers/http_scenario/ammo_hcl_test.go":"load/projects/pandora/components/providers/http_scenario/ammo_hcl_test.go",
"components/providers/http_scenario/decode.go":"load/projects/pandora/components/providers/http_scenario/decode.go",
"components/providers/http_scenario/decode_sample_config_test.golden.hcl":"load/projects/pandora/components/providers/http_scenario/decode_sample_config_test.golden.hcl",
"components/providers/http_scenario/decode_sample_config_test.hcl":"load/projects/pandora/components/providers/http_scenario/decode_sample_config_test.hcl",
"components/providers/http_scenario/decode_sample_config_test.yml":"load/projects/pandora/components/providers/http_scenario/decode_sample_config_test.yml",
"components/providers/http_scenario/decode_test.go":"load/projects/pandora/components/providers/http_scenario/decode_test.go",
"components/providers/http_scenario/import.go":"load/projects/pandora/components/providers/http_scenario/import.go",
"components/providers/http_scenario/postprocessor/assert_response.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/assert_response.go",
"components/providers/http_scenario/postprocessor/assert_response_test.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/assert_response_test.go",
"components/providers/http_scenario/postprocessor/postprocessor.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/postprocessor.go",
"components/providers/http_scenario/postprocessor/var_header.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_header.go",
"components/providers/http_scenario/postprocessor/var_header_test.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_header_test.go",
"components/providers/http_scenario/postprocessor/var_jsonpath.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_jsonpath.go",
"components/providers/http_scenario/postprocessor/var_jsonpath_test.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_jsonpath_test.go",
"components/providers/http_scenario/postprocessor/var_xpath.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_xpath.go",
"components/providers/http_scenario/postprocessor/var_xpath_test.go":"load/projects/pandora/components/providers/http_scenario/postprocessor/var_xpath_test.go",
"components/providers/http_scenario/preprocessor.go":"load/projects/pandora/components/providers/http_scenario/preprocessor.go",
"components/providers/http_scenario/preprocessor_test.go":"load/projects/pandora/components/providers/http_scenario/preprocessor_test.go",
"components/providers/http_scenario/provider.go":"load/projects/pandora/components/providers/http_scenario/provider.go",
"components/providers/http_scenario/templater.go":"load/projects/pandora/components/providers/http_scenario/templater.go",
"components/providers/http_scenario/templater_html.go":"load/projects/pandora/components/providers/http_scenario/templater_html.go",
"components/providers/http_scenario/templater_html_test.go":"load/projects/pandora/components/providers/http_scenario/templater_html_test.go",
"components/providers/http_scenario/templater_text.go":"load/projects/pandora/components/providers/http_scenario/templater_text.go",
"components/providers/http_scenario/templater_text_test.go":"load/projects/pandora/components/providers/http_scenario/templater_text_test.go",
"components/providers/http_scenario/vs.go":"load/projects/pandora/components/providers/http_scenario/vs.go",
"components/providers/http_scenario/vs_csv.go":"load/projects/pandora/components/providers/http_scenario/vs_csv.go",
"components/providers/http_scenario/vs_csv_test.go":"load/projects/pandora/components/providers/http_scenario/vs_csv_test.go",
"components/providers/http_scenario/vs_json.go":"load/projects/pandora/components/providers/http_scenario/vs_json.go",
"components/providers/http_scenario/vs_json_test.go":"load/projects/pandora/components/providers/http_scenario/vs_json_test.go",
"components/providers/http_scenario/vs_variables.go":"load/projects/pandora/components/providers/http_scenario/vs_variables.go",
"components/providers/scenario/config/config.go":"load/projects/pandora/components/providers/scenario/config/config.go",
"components/providers/scenario/config/decode.go":"load/projects/pandora/components/providers/scenario/config/decode.go",
"components/providers/scenario/config/decode_test.go":"load/projects/pandora/components/providers/scenario/config/decode_test.go",
"components/providers/scenario/config/hcl.go":"load/projects/pandora/components/providers/scenario/config/hcl.go",
"components/providers/scenario/config/hcl_test.go":"load/projects/pandora/components/providers/scenario/config/hcl_test.go",
"components/providers/scenario/http/decode.go":"load/projects/pandora/components/providers/scenario/http/decode.go",
"components/providers/scenario/http/decode_test.go":"load/projects/pandora/components/providers/scenario/http/decode_test.go",
"components/providers/scenario/http/postprocessor/assert_response.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/assert_response.go",
"components/providers/scenario/http/postprocessor/assert_response_test.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/assert_response_test.go",
"components/providers/scenario/http/postprocessor/postprocessor.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/postprocessor.go",
"components/providers/scenario/http/postprocessor/var_header.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_header.go",
"components/providers/scenario/http/postprocessor/var_header_test.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_header_test.go",
"components/providers/scenario/http/postprocessor/var_jsonpath.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_jsonpath.go",
"components/providers/scenario/http/postprocessor/var_jsonpath_test.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_jsonpath_test.go",
"components/providers/scenario/http/postprocessor/var_xpath.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_xpath.go",
"components/providers/scenario/http/postprocessor/var_xpath_test.go":"load/projects/pandora/components/providers/scenario/http/postprocessor/var_xpath_test.go",
"components/providers/scenario/http/preprocessor/preprocessor.go":"load/projects/pandora/components/providers/scenario/http/preprocessor/preprocessor.go",
"components/providers/scenario/http/preprocessor/preprocessor_test.go":"load/projects/pandora/components/providers/scenario/http/preprocessor/preprocessor_test.go",
"components/providers/scenario/http/provider.go":"load/projects/pandora/components/providers/scenario/http/provider.go",
"components/providers/scenario/http/templater/templater.go":"load/projects/pandora/components/providers/scenario/http/templater/templater.go",
"components/providers/scenario/http/templater/templater_html.go":"load/projects/pandora/components/providers/scenario/http/templater/templater_html.go",
"components/providers/scenario/http/templater/templater_html_test.go":"load/projects/pandora/components/providers/scenario/http/templater/templater_html_test.go",
"components/providers/scenario/http/templater/templater_text.go":"load/projects/pandora/components/providers/scenario/http/templater/templater_text.go",
"components/providers/scenario/http/templater/templater_text_test.go":"load/projects/pandora/components/providers/scenario/http/templater/templater_text_test.go",
"components/providers/scenario/import/import.go":"load/projects/pandora/components/providers/scenario/import/import.go",
"components/providers/scenario/provider.go":"load/projects/pandora/components/providers/scenario/provider.go",
"components/providers/scenario/test/decode_test.go":"load/projects/pandora/components/providers/scenario/test/decode_test.go",
"components/providers/scenario/test/vs_test.go":"load/projects/pandora/components/providers/scenario/test/vs_test.go",
"components/providers/scenario/testdata/grpc_payload.hcl":"load/projects/pandora/components/providers/scenario/testdata/grpc_payload.hcl",
"components/providers/scenario/testdata/grpc_payload.yaml":"load/projects/pandora/components/providers/scenario/testdata/grpc_payload.yaml",
"components/providers/scenario/testdata/http_payload.hcl":"load/projects/pandora/components/providers/scenario/testdata/http_payload.hcl",
"components/providers/scenario/testdata/http_payload.yaml":"load/projects/pandora/components/providers/scenario/testdata/http_payload.yaml",
"components/providers/scenario/vs/storage.go":"load/projects/pandora/components/providers/scenario/vs/storage.go",
"components/providers/scenario/vs/vs.go":"load/projects/pandora/components/providers/scenario/vs/vs.go",
"components/providers/scenario/vs/vs_csv.go":"load/projects/pandora/components/providers/scenario/vs/vs_csv.go",
"components/providers/scenario/vs/vs_csv_test.go":"load/projects/pandora/components/providers/scenario/vs/vs_csv_test.go",
"components/providers/scenario/vs/vs_json.go":"load/projects/pandora/components/providers/scenario/vs/vs_json.go",
"components/providers/scenario/vs/vs_json_test.go":"load/projects/pandora/components/providers/scenario/vs/vs_json_test.go",
"components/providers/scenario/vs/vs_variables.go":"load/projects/pandora/components/providers/scenario/vs/vs_variables.go",
"core/aggregator/discard.go":"load/projects/pandora/core/aggregator/discard.go",
"core/aggregator/encoder.go":"load/projects/pandora/core/aggregator/encoder.go",
"core/aggregator/encoder_test.go":"load/projects/pandora/core/aggregator/encoder_test.go",
Expand Down Expand Up @@ -253,6 +254,8 @@
"examples/debug_and_profiling.yaml":"load/projects/pandora/examples/debug_and_profiling.yaml",
"examples/http.jsonline":"load/projects/pandora/examples/http.jsonline",
"examples/http.yaml":"load/projects/pandora/examples/http.yaml",
"examples/http/server/server.go":"load/projects/pandora/examples/http/server/server.go",
"examples/http/server/stats.go":"load/projects/pandora/examples/http/server/stats.go",
"go.mod":"load/projects/pandora/gomod/go.mod",
"go.sum":"load/projects/pandora/gomod/go.sum",
"gomod/go.mod":"load/projects/pandora/gomod/go.mod",
Expand Down Expand Up @@ -312,5 +315,14 @@
"lib/zaputil/zaputil_suite_test.go":"load/projects/pandora/lib/zaputil/zaputil_suite_test.go",
"main.go":"load/projects/pandora/main.go",
"script/checkfmt.sh":"load/projects/pandora/script/checkfmt.sh",
"script/coverage.sh":"load/projects/pandora/script/coverage.sh"
"script/coverage.sh":"load/projects/pandora/script/coverage.sh",
"tests/acceptance/http_test.go":"load/projects/pandora/tests/acceptance/http_test.go",
"tests/acceptance/testdata/http/http.yaml":"load/projects/pandora/tests/acceptance/testdata/http/http.yaml",
"tests/acceptance/testdata/http/http2.yaml":"load/projects/pandora/tests/acceptance/testdata/http/http2.yaml",
"tests/acceptance/testdata/http/https.yaml":"load/projects/pandora/tests/acceptance/testdata/http/https.yaml",
"tests/acceptance/testdata/http/payload.uri":"load/projects/pandora/tests/acceptance/testdata/http/payload.uri",
"tests/http_scenario/main_test.go":"load/projects/pandora/tests/http_scenario/main_test.go",
"tests/http_scenario/testdata/filter.json":"load/projects/pandora/tests/http_scenario/testdata/filter.json",
"tests/http_scenario/testdata/http_payload.hcl":"load/projects/pandora/tests/http_scenario/testdata/http_payload.hcl",
"tests/http_scenario/testdata/users.csv":"load/projects/pandora/tests/http_scenario/testdata/users.csv"
}
12 changes: 6 additions & 6 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"go.uber.org/zap/zapcore"
)

const Version = "0.5.17"
const Version = "0.5.18"
const defaultConfigFile = "load"
const stdinConfigSelector = "-"

var configSearchDirs = []string{"./", "./config", "/etc/pandora"}

type cliConfig struct {
type CliConfig struct {
Engine engine.Config `config:",squash"`
Log logConfig `config:"log"`
Monitoring monitoringConfig `config:"monitoring"`
Expand All @@ -56,8 +56,8 @@ func newLogger(conf logConfig) *zap.Logger {
return log
}

func defaultConfig() *cliConfig {
return &cliConfig{
func DefaultConfig() *CliConfig {
return &CliConfig{
Log: logConfig{
Level: zap.InfoLevel,
File: "stdout",
Expand Down Expand Up @@ -191,7 +191,7 @@ func runEngine(ctx context.Context, engine *engine.Engine, errs chan error) {
errs <- engine.Run(ctx)
}

func readConfig(args []string) *cliConfig {
func readConfig(args []string) *CliConfig {
log, err := zap.NewDevelopment(zap.AddCaller())
if err != nil {
panic(err)
Expand Down Expand Up @@ -236,7 +236,7 @@ func readConfig(args []string) *cliConfig {
}
}

conf := defaultConfig()
conf := DefaultConfig()
err = config.DecodeAndValidate(v.AllSettings(), conf)
if err != nil {
log.Fatal("Config decode failed", zap.Error(err))
Expand Down
2 changes: 1 addition & 1 deletion components/guns/grpc/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (g *Gun) AcceptWarmUpResult(i interface{}) error {
}

func NewGun(conf GunConfig) *Gun {
answLog := answlog.Init(conf.AnswLog.Path)
answLog := answlog.Init(conf.AnswLog.Path, conf.AnswLog.Enabled)
return &Gun{conf: conf, answLog: answLog}
}

Expand Down
72 changes: 43 additions & 29 deletions components/guns/http_scenario/ammo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,49 @@ import (
"time"
)

//go:generate go run github.com/vektra/mockery/[email protected] --inpackage --name=Preprocessor --filename=mock_preprocessor_test.go
//go:generate go run github.com/vektra/mockery/[email protected] --inpackage --name=Postprocessor --filename=mock_postprocessor_test.go
//go:generate go run github.com/vektra/mockery/[email protected] --inpackage --name=Step --filename=mock_step_test.go
//go:generate go run github.com/vektra/mockery/[email protected] --inpackage --name=Ammo --filename=mock_ammo_test.go
type SourceStorage interface {
Variables() map[string]any
}

type Scenario struct {
Requests []Request
ID uint64
Name string
MinWaitingTime time.Duration
VariableStorage SourceStorage
}

func (a *Scenario) SetID(id uint64) {
a.ID = id
}

type Request struct {
Method string
Headers map[string]string
Tag string
Body *string
Name string
URI string
Preprocessor Preprocessor
Postprocessors []Postprocessor
Templater Templater
Sleep time.Duration
}

func (r *Request) GetBody() []byte {
if r.Body == nil {
return nil
}
return []byte(*r.Body)
}

func (r *Request) GetHeaders() map[string]string {
result := make(map[string]string, len(r.Headers))
for k, v := range r.Headers {
result[k] = v
}
return result
}

type Preprocessor interface {
// Process is called before request is sent
Expand All @@ -22,34 +61,9 @@ type Postprocessor interface {
Process(resp *http.Response, body io.Reader) (map[string]any, error)
}

type VariableStorage interface {
Variables() map[string]any
}

type Step interface {
GetName() string
GetURL() string
GetMethod() string
GetBody() []byte
GetHeaders() map[string]string
GetTag() string
GetTemplater() Templater
GetPostProcessors() []Postprocessor
Preprocessor() Preprocessor
GetSleep() time.Duration
}

type RequestParts struct {
URL string
Method string
Body []byte
Headers map[string]string
}

type Ammo interface {
Steps() []Step
ID() uint64
Sources() VariableStorage
Name() string
GetMinWaitingTime() time.Duration
}
Loading

0 comments on commit 33abe68

Please sign in to comment.