Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.5.17 #176

Merged
merged 6 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
release:
types: [created]

permissions:
contents: write
packages: write

jobs:
releases-matrix:
name: Release Go Binary
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
arch: [amd64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
cache: true

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

- name: Set GITHUB_ENV
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "GOOS=linux" >> $GITHUB_ENV
else
echo "GOOS=darwin" >> $GITHUB_ENV
fi

- name: Build
run: |
export GOARCH=${{ matrix.arch }}
export CGO_ENABLED=0
go build -o pandora_${{ github.event.release.tag_name }}_${GOOS}_${{ matrix.arch }}

- name: Release
uses: softprops/action-gh-release@v1
with:
files: pandora_${{ github.event.release.tag_name }}_${{ env.GOOS }}_${{ matrix.arch }}
2 changes: 1 addition & 1 deletion .mapping.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
".github/workflows/release.yml":"load/projects/pandora/.github/workflows/release.yml",
".github/workflows/test.yml":"load/projects/pandora/.github/workflows/test.yml",
".gitignore":"load/projects/pandora/.gitignore",
".goxc.json":"load/projects/pandora/.goxc.json",
Expand Down Expand Up @@ -161,7 +162,6 @@
"core/datasource/file_test.go":"load/projects/pandora/core/datasource/file_test.go",
"core/datasource/std.go":"load/projects/pandora/core/datasource/std.go",
"core/engine/engine.go":"load/projects/pandora/core/engine/engine.go",
"core/engine/engine_suite_test.go":"load/projects/pandora/core/engine/engine_suite_test.go",
"core/engine/engine_test.go":"load/projects/pandora/core/engine/engine_test.go",
"core/engine/instance.go":"load/projects/pandora/core/engine/instance.go",
"core/engine/instance_test.go":"load/projects/pandora/core/engine/instance_test.go",
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Pandora

[![Release](https://github.com/yandex/pandora/actions/workflows/release.yml/badge.svg)](https://github.com/yandex/pandora/actions/workflows/release.yml)
[![Release](https://img.shields.io/github/v/release/yandex/pandora.svg?style=flat-square)](https://github.com/yandex/pandora/releases)
[![Test](https://github.com/yandex/pandora/actions/workflows/test.yml/badge.svg)](https://github.com/yandex/pandora/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/yandex/pandora/badge.svg?precision=2)](https://app.codecov.io/gh/yandex/pandora)
![Code lines](https://sloc.xyz/github/yandex/pandora/?category=code)

[![PkgGoDev](https://pkg.go.dev/badge/github.com/yandex/pandora)](https://pkg.go.dev/github.com/yandex/pandora)
[![Go Report Card](https://goreportcard.com/badge/github.com/yandex/pandora)](https://goreportcard.com/report/github.com/yandex/pandora)
[![Join the chat at https://gitter.im/yandex/pandora](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yandex/pandora?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/yandex/pandora.svg)](https://travis-ci.org/yandex/pandora)
[![Coverage Status](https://coveralls.io/repos/yandex/pandora/badge.svg?branch=develop&service=github)](https://coveralls.io/github/yandex/pandora?branch=develop)
[![Documentation Status](https://readthedocs.org/projects/yandexpandora/badge/?version=develop)](https://yandexpandora.readthedocs.io/en/develop/?badge=develop)

Pandora is a high-performance load generator in Go language. It has built-in HTTP(S) and HTTP/2 support and you can write your own load scenarios in Go, compiling them just before your test.

Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"go.uber.org/zap/zapcore"
)

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

Expand Down
19 changes: 9 additions & 10 deletions core/coreutil/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@ import (
// Waiter goroutine unsafe wrapper for efficient waiting schedule.
type Waiter struct {
sched core.Schedule
ctx context.Context
slowDownItems int

// Lazy initialized.
timer *time.Timer
lastNow time.Time
}

func NewWaiter(sched core.Schedule, ctx context.Context) *Waiter {
return &Waiter{sched: sched, ctx: ctx}
func NewWaiter(sched core.Schedule) *Waiter {
return &Waiter{sched: sched}
}

// Wait waits for next waiter schedule event.
// Returns true, if event successfully waited, or false
// if waiter context is done, or schedule finished.
func (w *Waiter) Wait() (ok bool) {
func (w *Waiter) Wait(ctx context.Context) (ok bool) {
// Check, that context is not done. Very quick: 5 ns for op, due to benchmark.
select {
case <-w.ctx.Done():
case <-ctx.Done():
w.slowDownItems = 0
return false
default:
Expand Down Expand Up @@ -65,15 +64,15 @@ func (w *Waiter) Wait() (ok bool) {
select {
case <-w.timer.C:
return true
case <-w.ctx.Done():
case <-ctx.Done():
return false
}
}

// IsSlowDown returns true, if schedule contains 2 elements before current time.
func (w *Waiter) IsSlowDown() (ok bool) {
func (w *Waiter) IsSlowDown(ctx context.Context) (ok bool) {
select {
case <-w.ctx.Done():
case <-ctx.Done():
return false
default:
return w.slowDownItems >= 2
Expand All @@ -82,9 +81,9 @@ func (w *Waiter) IsSlowDown() (ok bool) {

// IsFinished is quick check, that wait context is not canceled and there are some tokens left in
// schedule.
func (w *Waiter) IsFinished() (ok bool) {
func (w *Waiter) IsFinished(ctx context.Context) (ok bool) {
select {
case <-w.ctx.Done():
case <-ctx.Done():
return true
default:
return w.sched.Left() == 0
Expand Down
18 changes: 9 additions & 9 deletions core/coreutil/waiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
func TestWaiter_Unstarted(t *testing.T) {
sched := schedule.NewOnce(1)
ctx := context.Background()
w := NewWaiter(sched, ctx)
w := NewWaiter(sched)
var i int
for ; w.Wait(); i++ {
for ; w.Wait(ctx); i++ {
}
require.Equal(t, 1, i)
}
Expand All @@ -31,11 +31,11 @@ func TestWaiter_WaitAsExpected(t *testing.T) {
)
sched := schedule.NewConst(ops, duration)
ctx := context.Background()
w := NewWaiter(sched, ctx)
w := NewWaiter(sched)
start := time.Now()
sched.Start(start)
var i int
for ; w.Wait(); i++ {
for ; w.Wait(ctx); i++ {
}
finish := time.Now()

Expand All @@ -48,8 +48,8 @@ func TestWaiter_ContextCanceledBeforeWait(t *testing.T) {
sched := schedule.NewOnce(1)
ctx, cancel := context.WithCancel(context.Background())
cancel()
w := NewWaiter(sched, ctx)
require.False(t, w.Wait())
w := NewWaiter(sched)
require.False(t, w.Wait(ctx))
}

func TestWaiter_ContextCanceledDuringWait(t *testing.T) {
Expand All @@ -58,10 +58,10 @@ func TestWaiter_ContextCanceledDuringWait(t *testing.T) {
start := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
w := NewWaiter(sched, ctx)
w := NewWaiter(sched)

require.True(t, w.Wait()) // 0
require.False(t, w.Wait())
require.True(t, w.Wait(ctx)) // 0
require.False(t, w.Wait(ctx))

since := time.Since(start)
require.True(t, since > timeout)
Expand Down
6 changes: 3 additions & 3 deletions core/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ func (p *instancePool) startInstances(
},
}

waiter := coreutil.NewWaiter(p.StartupSchedule, startCtx)
waiter := coreutil.NewWaiter(p.StartupSchedule)

// If create all instances asynchronously, and creation will fail, too many errors appears in log.
ok := waiter.Wait()
ok := waiter.Wait(startCtx)
if !ok {
err = startCtx.Err()
return
Expand All @@ -393,7 +393,7 @@ func (p *instancePool) startInstances(
}()}
}()

for ; waiter.Wait(); started++ {
for ; waiter.Wait(startCtx); started++ {
id := started
go func() {
runRes <- instanceRunResult{id, runNewInstance(runCtx, p.log, p.ID, id, deps)}
Expand Down
21 changes: 0 additions & 21 deletions core/engine/engine_suite_test.go

This file was deleted.

Loading