From 26579f078e3a9915fbfcdc867e57c9d3f8b43232 Mon Sep 17 00:00:00 2001 From: tarhphilomina <156124227+tarhphilomina@users.noreply.github.com> Date: Thu, 18 Jan 2024 05:05:33 +0100 Subject: [PATCH] Added test on plugin/sampling/strategystore/adaptive/options (#5105) ## 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> --- .../strategystore/adaptive/options_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 plugin/sampling/strategystore/adaptive/options_test.go diff --git a/plugin/sampling/strategystore/adaptive/options_test.go b/plugin/sampling/strategystore/adaptive/options_test.go new file mode 100644 index 00000000000..1ab64c0589c --- /dev/null +++ b/plugin/sampling/strategystore/adaptive/options_test.go @@ -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) +}