1// Copyright 2017 Istio Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Package test supplies a fake Mixer server for use in testing. It should NOT
16// be used outside of testing contexts.
17package perftests
18
19import (
20	"testing"
21
22	"istio.io/istio/mixer/pkg/perf"
23)
24
25// Basic reporting setup using multiple reported metric values in a request.
26//
27// This is a step-up from singlereport, as builds and instance from expressions, thus exercising generated template code.
28
29var baseMultiMetricSetup = perf.Setup{
30	Config: perf.Config{
31		Global:         minimalServiceConfig,
32		Service:        joinConfigs(h1Noop, i3Metric, i4Metric, i5Metric, i6Metric, i7Metric, r6UsingH1AndI3To7),
33		SingleThreaded: true,
34	},
35
36	Loads: []perf.Load{{
37		Multiplier: 1,
38		Requests: []perf.Request{
39			perf.BuildBasicReport(map[string]interface{}{
40				"source.service":      "AcmeService",
41				"source.labels":       map[string]string{"version": "23"},
42				"destination.service": "DevNullService",
43				"destination.labels":  map[string]string{"version": "42"},
44				"response.code":       int64(200),
45				"request.size":        int64(666),
46			}),
47		},
48	}},
49}
50
51func Benchmark_Multi_Metric(b *testing.B) {
52	settings := baseSettings
53	settings.RunMode = perf.InProcessBypassGrpc
54
55	setup := baseMultiMetricSetup
56
57	perf.Run(b, &setup, settings)
58}
59
60func Benchmark_Multi_Metric_Rpc(b *testing.B) {
61	settings := baseSettings
62	settings.RunMode = perf.InProcess
63
64	setup := baseMultiMetricSetup
65
66	perf.Run(b, &setup, settings)
67}
68