Skip to content

Commit

Permalink
Added test on plugin/sampling/strategystore/adaptive/options (#5105)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
Part of  #5068 

## Description of the changes
- Added test to adaptive sampling plugin options

## How was this change tested?
- make test

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: tarhphilomina <156124227+tarhphilomina@users.noreply.github.com>
  • Loading branch information
tarhphilomina committed Jan 18, 2024
1 parent 663a04e commit 26579f0
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions plugin/sampling/strategystore/adaptive/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package adaptive

import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/jaegertracing/jaeger/pkg/config"
)

func TestOptionsWithFlags(t *testing.T) {
v, command := config.Viperize(AddFlags)
command.ParseFlags([]string{
"--sampling.target-samples-per-second=2.0",
"--sampling.delta-tolerance=0.6",
"--sampling.buckets-for-calculation=2",
"--sampling.calculation-interval=2m0s",
"--sampling.aggregation-buckets=20",
"--sampling.delay=6m0s",
"--sampling.initial-sampling-probability=0.002",
"--sampling.min-sampling-probability=1e-4",
"--sampling.min-samples-per-second=0.016666666666666666",
"--sampling.leader-lease-refresh-interval=5s",
"--sampling.follower-lease-refresh-interval=1m0s",
})
opts := &Options{}

opts.InitFromViper(v)

assert.Equal(t, 2.0, opts.TargetSamplesPerSecond)
assert.Equal(t, 0.6, opts.DeltaTolerance)
assert.Equal(t, 2, opts.BucketsForCalculation)
assert.Equal(t, time.Duration(120000000000), opts.CalculationInterval)
assert.Equal(t, 20, opts.AggregationBuckets)
assert.Equal(t, time.Duration(360000000000), opts.Delay)
assert.Equal(t, 0.002, opts.InitialSamplingProbability)
assert.Equal(t, 1e-4, opts.MinSamplingProbability)
assert.Equal(t, 0.016666666666666666, opts.MinSamplesPerSecond)
assert.Equal(t, time.Duration(5000000000), opts.LeaderLeaseRefreshInterval)
assert.Equal(t, time.Duration(60000000000), opts.FollowerLeaseRefreshInterval)
}

0 comments on commit 26579f0

Please sign in to comment.