mirror of https://github.com/knative/caching.git
Auto-update dependencies (#139)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott
This commit is contained in:
parent
067b78720a
commit
14ff67345c
|
@ -933,7 +933,7 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:bfedb6d5106671cef84df18463d0fbf360a85916980675aac8b49690fd594c36"
|
||||
digest = "1:c2a4335822f3689f4322e6b814a280932b3064079e9792ff3da51987313602de"
|
||||
name = "knative.dev/pkg"
|
||||
packages = [
|
||||
"apis",
|
||||
|
@ -952,18 +952,18 @@
|
|||
"metrics/metricskey",
|
||||
]
|
||||
pruneopts = "T"
|
||||
revision = "d9e3e244a6c044379b71d90b7440daad5b7910f3"
|
||||
revision = "2ec0f8da50578dcc3d830571d0de24de834579c8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:e4a2fd481bd2d6dcac5ae03c55d6104a0953d0a78cb45fdd4d20a116ed2a5218"
|
||||
digest = "1:85fe0cadd6ab83f3d7f948c60b6d422dc9cd16664246249968dab5d828ae8dfd"
|
||||
name = "knative.dev/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "6faacbd40140c782d8a1261321b99a402967a6a8"
|
||||
revision = "fad831028edbe066665977ea7bf366c3d5c0a2d1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||
|
|
|
@ -355,6 +355,14 @@
|
|||
pruneopts = "NUT"
|
||||
revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:cf68a79fd02ab0f6942b9567d03d054b6568212fcc22de2a4afdefd096923749"
|
||||
name = "github.com/kballard/go-shellquote"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "95032a82bc518f77982ea72343cc1ade730072f0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:58999a98719fddbac6303cb17e8d85b945f60b72f48e3a2df6b950b97fa926f1"
|
||||
name = "github.com/konsorten/go-windows-terminal-sequences"
|
||||
|
@ -1260,14 +1268,14 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:e4a2fd481bd2d6dcac5ae03c55d6104a0953d0a78cb45fdd4d20a116ed2a5218"
|
||||
digest = "1:85fe0cadd6ab83f3d7f948c60b6d422dc9cd16664246249968dab5d828ae8dfd"
|
||||
name = "knative.dev/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "e381f11dc722330fe082158e2f22cd39f8fe8375"
|
||||
revision = "fad831028edbe066665977ea7bf366c3d5c0a2d1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||
|
@ -1302,6 +1310,7 @@
|
|||
"github.com/google/mako/spec/proto/mako_go_proto",
|
||||
"github.com/google/uuid",
|
||||
"github.com/gorilla/websocket",
|
||||
"github.com/kballard/go-shellquote",
|
||||
"github.com/markbates/inflect",
|
||||
"github.com/mattbaird/jsonpatch",
|
||||
"github.com/openzipkin/zipkin-go",
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Copyright 2018 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"knative.dev/pkg/apis"
|
||||
"knative.dev/pkg/apis/duck"
|
||||
)
|
||||
|
||||
// PodSpecable is implemented by types containing a PodTemplateSpec
|
||||
// in the manner of ReplicaSet, Deployment, DaemonSet, StatefulSet.
|
||||
type PodSpecable corev1.PodTemplateSpec
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// WithPod is the shell that demonstrates how PodSpecable types wrap
|
||||
// a PodSpec.
|
||||
type WithPod struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec WithPodSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// WithPodSpec is the shell around the PodSpecable within WithPod.
|
||||
type WithPodSpec struct {
|
||||
Template PodSpecable `json:"template,omitempty"`
|
||||
}
|
||||
|
||||
// Assert that we implement the interfaces necessary to
|
||||
// use duck.VerifyType.
|
||||
var (
|
||||
_ duck.Populatable = (*WithPod)(nil)
|
||||
_ duck.Implementable = (*PodSpecable)(nil)
|
||||
_ apis.Listable = (*WithPod)(nil)
|
||||
)
|
||||
|
||||
// GetFullType implements duck.Implementable
|
||||
func (*PodSpecable) GetFullType() duck.Populatable {
|
||||
return &WithPod{}
|
||||
}
|
||||
|
||||
// Populate implements duck.Populatable
|
||||
func (t *WithPod) Populate() {
|
||||
t.Spec.Template = PodSpecable{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{{
|
||||
Name: "container-name",
|
||||
Image: "container-image:latest",
|
||||
}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetListType implements apis.Listable
|
||||
func (*WithPod) GetListType() runtime.Object {
|
||||
return &WithPodList{}
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// WithPodList is a list of WithPod resources
|
||||
type WithPodList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []WithPod `json:"items"`
|
||||
}
|
|
@ -49,6 +49,10 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
(&KResource{}).GetListType(),
|
||||
&AddressableType{},
|
||||
(&AddressableType{}).GetListType(),
|
||||
&Source{},
|
||||
(&Source{}).GetListType(),
|
||||
&WithPod{},
|
||||
(&WithPod{}).GetListType(),
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
|
|
|
@ -259,6 +259,24 @@ func (in *KResourceList) DeepCopyObject() runtime.Object {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PodSpecable) DeepCopyInto(out *PodSpecable) {
|
||||
*out = *in
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSpecable.
|
||||
func (in *PodSpecable) DeepCopy() *PodSpecable {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(PodSpecable)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Source) DeepCopyInto(out *Source) {
|
||||
*out = *in
|
||||
|
@ -386,3 +404,80 @@ func (in *Status) DeepCopy() *Status {
|
|||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WithPod) DeepCopyInto(out *WithPod) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPod.
|
||||
func (in *WithPod) DeepCopy() *WithPod {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WithPod)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *WithPod) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WithPodList) DeepCopyInto(out *WithPodList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]WithPod, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPodList.
|
||||
func (in *WithPodList) DeepCopy() *WithPodList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WithPodList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *WithPodList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WithPodSpec) DeepCopyInto(out *WithPodSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPodSpec.
|
||||
func (in *WithPodSpec) DeepCopy() *WithPodSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WithPodSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Copyright 2019 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
shell "github.com/kballard/go-shellquote"
|
||||
|
||||
"knative.dev/pkg/test/helpers"
|
||||
)
|
||||
|
||||
const (
|
||||
invalidInputErrorPrefix = "invalid input: "
|
||||
defaultErrCode = 1
|
||||
separator = "\n"
|
||||
)
|
||||
|
||||
// RunCommand will run the command and return the standard output, plus error if there is one.
|
||||
func RunCommand(cmdLine string) (string, error) {
|
||||
cmdSplit, err := shell.Split(cmdLine)
|
||||
if len(cmdSplit) == 0 || err != nil {
|
||||
return "", &CommandLineError{
|
||||
Command: cmdLine,
|
||||
ErrorOutput: []byte(invalidInputErrorPrefix + cmdLine),
|
||||
ErrorCode: defaultErrCode,
|
||||
}
|
||||
}
|
||||
|
||||
cmdName := cmdSplit[0]
|
||||
args := cmdSplit[1:]
|
||||
cmd := exec.Command(cmdName, args...)
|
||||
var eb bytes.Buffer
|
||||
cmd.Stderr = &eb
|
||||
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return string(out), &CommandLineError{
|
||||
Command: cmdLine,
|
||||
ErrorOutput: eb.Bytes(),
|
||||
ErrorCode: getErrorCode(err),
|
||||
}
|
||||
}
|
||||
|
||||
return string(out), nil
|
||||
}
|
||||
|
||||
// RunCommands will run the commands sequentially.
|
||||
// If there is an error when running a command, it will return directly with all standard output so far and the error.
|
||||
func RunCommands(cmdLines ...string) (string, error) {
|
||||
var outputs []string
|
||||
for _, cmdLine := range cmdLines {
|
||||
output, err := RunCommand(cmdLine)
|
||||
outputs = append(outputs, output)
|
||||
if err != nil {
|
||||
return strings.Join(outputs, separator), err
|
||||
}
|
||||
}
|
||||
return strings.Join(outputs, separator), nil
|
||||
}
|
||||
|
||||
// RunCommandsInParallel will run the commands in parallel.
|
||||
// It will always finish running all commands, and return all standard output and errors together.
|
||||
func RunCommandsInParallel(cmdLines ...string) (string, error) {
|
||||
errCh := make(chan error, len(cmdLines))
|
||||
outputCh := make(chan string, len(cmdLines))
|
||||
mx := sync.Mutex{}
|
||||
wg := sync.WaitGroup{}
|
||||
for i := range cmdLines {
|
||||
cmdLine := cmdLines[i]
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
output, err := RunCommand(cmdLine)
|
||||
mx.Lock()
|
||||
outputCh <- output
|
||||
errCh <- err
|
||||
mx.Unlock()
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(outputCh)
|
||||
close(errCh)
|
||||
|
||||
os := make([]string, 0, len(cmdLines))
|
||||
es := make([]error, 0, len(cmdLines))
|
||||
for o := range outputCh {
|
||||
os = append(os, o)
|
||||
}
|
||||
for e := range errCh {
|
||||
es = append(es, e)
|
||||
}
|
||||
|
||||
return strings.Join(os, separator), helpers.CombineErrors(es)
|
||||
}
|
||||
|
||||
// getErrorCode extracts the exit code of an *ExitError type
|
||||
func getErrorCode(err error) int {
|
||||
errorCode := defaultErrCode
|
||||
if exitError, ok := err.(*exec.ExitError); ok {
|
||||
errorCode = exitError.ExitCode()
|
||||
}
|
||||
return errorCode
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright 2019 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
// CommandLineError is a custom error we use for errors got from running commands
|
||||
type CommandLineError struct {
|
||||
Command string
|
||||
ErrorCode int
|
||||
ErrorOutput []byte
|
||||
}
|
||||
|
||||
func (c CommandLineError) Error() string {
|
||||
return string(c.ErrorOutput)
|
||||
}
|
|
@ -28,10 +28,14 @@ func CombineErrors(errs []error) error {
|
|||
if len(errs) == 0 {
|
||||
return nil
|
||||
}
|
||||
var sb strings.Builder
|
||||
msgs := make([]string, 0)
|
||||
for _, err := range errs {
|
||||
sb.WriteString(err.Error())
|
||||
sb.WriteString("\n")
|
||||
if err != nil {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
}
|
||||
return errors.New(strings.Trim(sb.String(), "\n"))
|
||||
if len(msgs) == 0 {
|
||||
return nil
|
||||
}
|
||||
return errors.New(strings.Join(msgs, "\n"))
|
||||
}
|
||||
|
|
|
@ -28,36 +28,40 @@ import (
|
|||
)
|
||||
|
||||
const koDataPathEnvName = "KO_DATA_PATH"
|
||||
const configMako = "/etc/config-mako"
|
||||
|
||||
// MustGetBenchmark wraps getBenchmark in log.Fatalf
|
||||
func MustGetBenchmark() (*string, *string) {
|
||||
benchmarkKey, benchmarkName, err := getBenchmark()
|
||||
func MustGetBenchmark() *mpb.BenchmarkInfo {
|
||||
bench, err := getBenchmark()
|
||||
if err != nil {
|
||||
log.Fatalf("unable to determine benchmark_key: %v", err)
|
||||
log.Fatalf("unable to determine benchmark info: %v", err)
|
||||
}
|
||||
return benchmarkKey, benchmarkName
|
||||
return bench
|
||||
}
|
||||
|
||||
// getBenchmark fetches the appropriate benchmark_key for this configured environment.
|
||||
func getBenchmark() (*string, *string, error) {
|
||||
func getBenchmark() (*mpb.BenchmarkInfo, error) {
|
||||
// Figure out what environment we're running in from the Mako configmap.
|
||||
env, err := getEnvironment()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
// Read the Mako config file for this environment.
|
||||
data, err := readFileFromKoData(env + ".config")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
data, koerr := readFileFromKoData(env + ".config")
|
||||
if koerr != nil {
|
||||
data, err = ioutil.ReadFile(filepath.Join(configMako, env+".config"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load both from kodata and from config mako config map: %s, %s", koerr.Error(), err.Error())
|
||||
}
|
||||
}
|
||||
// Parse the Mako config file.
|
||||
bi := &mpb.BenchmarkInfo{}
|
||||
if err := proto.UnmarshalText(string(data), bi); err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Return the benchmark_key from this environment's config file.
|
||||
return bi.BenchmarkKey, bi.BenchmarkName, nil
|
||||
return bi, nil
|
||||
}
|
||||
|
||||
// readFileFromKoData reads the named file from kodata.
|
||||
|
|
|
@ -176,12 +176,8 @@ func SetupHelper(ctx context.Context, benchmarkKey *string, benchmarkName *strin
|
|||
}
|
||||
|
||||
func Setup(ctx context.Context, extraTags ...string) (*Client, error) {
|
||||
benchmarkKey, benchmarkName := config.MustGetBenchmark()
|
||||
return SetupHelper(ctx, benchmarkKey, benchmarkName, extraTags...)
|
||||
}
|
||||
|
||||
func SetupWithBenchmarkConfig(ctx context.Context, benchmarkKey *string, benchmarkName *string, extraTags ...string) (*Client, error) {
|
||||
return SetupHelper(ctx, benchmarkKey, benchmarkName, extraTags...)
|
||||
bench := config.MustGetBenchmark()
|
||||
return SetupHelper(ctx, bench.BenchmarkKey, bench.BenchmarkName, extraTags...)
|
||||
}
|
||||
|
||||
func tokenPath(token string) string {
|
||||
|
|
|
@ -19,104 +19,150 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"encoding/csv"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
mako "github.com/google/mako/spec/proto/mako_go_proto"
|
||||
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"knative.dev/pkg/test/mako/config"
|
||||
qspb "knative.dev/pkg/third_party/mako/proto/quickstore_go_proto"
|
||||
)
|
||||
|
||||
const (
|
||||
port = ":9813"
|
||||
// A 10 minutes run at 1000 rps of eventing perf tests is usually ~= 70 MBi, so 100MBi is reasonable
|
||||
defaultServerMaxReceiveMessageSize = 1024 * 1024 * 100
|
||||
port = ":9813"
|
||||
defaultServerMaxReceiveMessageSize = 1024 * 1024 * 1024
|
||||
)
|
||||
|
||||
type server struct {
|
||||
info *mako.BenchmarkInfo
|
||||
stopOnce sync.Once
|
||||
stopCh chan struct{}
|
||||
sb *strings.Builder
|
||||
}
|
||||
|
||||
func (s *server) Store(ctx context.Context, in *qspb.StoreInput) (*qspb.StoreOutput, error) {
|
||||
m := jsonpb.Marshaler{}
|
||||
qi, _ := m.MarshalToString(in.GetQuickstoreInput())
|
||||
fmt.Printf("# %s\n", qi)
|
||||
cols := []string{"inputValue", "errorMessage"}
|
||||
writer := csv.NewWriter(os.Stdout)
|
||||
fmt.Printf("# Received input")
|
||||
|
||||
fmt.Fprintf(s.sb, "# %s\n", qi)
|
||||
writer := csv.NewWriter(s.sb)
|
||||
|
||||
kv := calculateKeyIndexColumnsMap(s.info)
|
||||
cols := make([]string, len(kv))
|
||||
for k, i := range kv {
|
||||
cols[i] = k
|
||||
}
|
||||
fmt.Fprintf(s.sb, "# %s\n", strings.Join(cols, ","))
|
||||
|
||||
for _, sp := range in.GetSamplePoints() {
|
||||
for _, mv := range sp.GetMetricValueList() {
|
||||
cols = updateCols(cols, mv.GetValueKey())
|
||||
vals := map[string]string{"inputValue": fmt.Sprintf("%f", sp.GetInputValue())}
|
||||
vals[mv.GetValueKey()] = fmt.Sprintf("%f", mv.GetValue())
|
||||
writer.Write(makeRow(cols, vals))
|
||||
writer.Write(makeRow(vals, kv))
|
||||
}
|
||||
}
|
||||
|
||||
for _, ra := range in.GetRunAggregates() {
|
||||
cols = updateCols(cols, ra.GetValueKey())
|
||||
vals := map[string]string{ra.GetValueKey(): fmt.Sprintf("%f", ra.GetValue())}
|
||||
writer.Write(makeRow(cols, vals))
|
||||
writer.Write(makeRow(vals, kv))
|
||||
}
|
||||
|
||||
for _, sa := range in.GetSampleErrors() {
|
||||
vals := map[string]string{"inputValue": fmt.Sprintf("%f", sa.GetInputValue()), "errorMessage": sa.GetErrorMessage()}
|
||||
writer.Write(makeRow(cols, vals))
|
||||
writer.Write(makeRow(vals, kv))
|
||||
}
|
||||
|
||||
writer.Flush()
|
||||
fmt.Printf("# %s\n", strings.Join(cols, ","))
|
||||
|
||||
fmt.Fprintf(s.sb, "# CSV end\n")
|
||||
fmt.Printf("# Input completed")
|
||||
|
||||
return &qspb.StoreOutput{}, nil
|
||||
}
|
||||
|
||||
func updateCols(prototype []string, k string) []string {
|
||||
for _, n := range prototype {
|
||||
if n == k {
|
||||
return prototype
|
||||
}
|
||||
}
|
||||
prototype = append(prototype, k)
|
||||
return prototype
|
||||
}
|
||||
|
||||
func makeRow(prototype []string, points map[string]string) []string {
|
||||
row := make([]string, len(prototype))
|
||||
// n^2 but whatever
|
||||
func makeRow(points map[string]string, kv map[string]int) []string {
|
||||
row := make([]string, len(kv))
|
||||
for k, v := range points {
|
||||
for i, n := range prototype {
|
||||
if k == n {
|
||||
row[i] = v
|
||||
}
|
||||
}
|
||||
row[kv[k]] = v
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
||||
func calculateKeyIndexColumnsMap(info *mako.BenchmarkInfo) map[string]int {
|
||||
kv := make(map[string]int)
|
||||
kv["inputValue"] = 0
|
||||
kv["errorMessage"] = 1
|
||||
for i, m := range info.MetricInfoList {
|
||||
kv[*m.ValueKey] = i + 2
|
||||
}
|
||||
return kv
|
||||
}
|
||||
|
||||
func (s *server) ShutdownMicroservice(ctx context.Context, in *qspb.ShutdownInput) (*qspb.ShutdownOutput, error) {
|
||||
s.stopOnce.Do(func() { close(s.stopCh) })
|
||||
return &qspb.ShutdownOutput{}, nil
|
||||
}
|
||||
|
||||
var httpPort int
|
||||
|
||||
func init() {
|
||||
flag.IntVar(&httpPort, "p", 0, "Port to use for using stub in HTTP mode. 0 means print to logs and quit")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
lis, err := net.Listen("tcp", port)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
s := grpc.NewServer(grpc.MaxRecvMsgSize(defaultServerMaxReceiveMessageSize))
|
||||
stopCh := make(chan struct{})
|
||||
info := config.MustGetBenchmark()
|
||||
var sb strings.Builder
|
||||
|
||||
fmt.Fprintf(&sb, "# Benchmark %s - %s\n", *info.BenchmarkKey, *info.BenchmarkName)
|
||||
|
||||
go func() {
|
||||
qspb.RegisterQuickstoreServer(s, &server{stopCh: stopCh})
|
||||
qspb.RegisterQuickstoreServer(s, &server{info: info, stopCh: stopCh, sb: &sb})
|
||||
if err := s.Serve(lis); err != nil {
|
||||
log.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
}()
|
||||
<-stopCh
|
||||
s.GracefulStop()
|
||||
|
||||
results := sb.String()
|
||||
|
||||
if httpPort != 0 {
|
||||
m := http.NewServeMux()
|
||||
s := http.Server{Addr: fmt.Sprintf(":%d", httpPort), Handler: m}
|
||||
|
||||
m.HandleFunc("/results", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("content-type", "text/csv")
|
||||
_, err := fmt.Fprint(w, results)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
m.HandleFunc("/close", func(writer http.ResponseWriter, request *http.Request) {
|
||||
s.Shutdown(context.Background())
|
||||
})
|
||||
if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Print("Successfully served the results")
|
||||
} else {
|
||||
fmt.Print(sb.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2019 The Knative Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This scripts helps to read results of mako-stub from http
|
||||
|
||||
check_command_exists() {
|
||||
CMD_NAME=$1
|
||||
command -v "$CMD_NAME" > /dev/null || {
|
||||
echo "Command $CMD_NAME does not exist"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
check_command_exists kubectl
|
||||
check_command_exists curl
|
||||
|
||||
if [[ $# -lt 7 ]]
|
||||
then
|
||||
echo "Usage: $0 <mako_stub_pod_name> <mako_stub_namespace> <mako_stub_port> <timeout> <retries> <retries_interval> <out_file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAKO_STUB_POD_NAME="$1"
|
||||
MAKO_STUB_NAMESPACE="$2"
|
||||
MAKO_STUB_PORT="$3"
|
||||
TIMEOUT="$4"
|
||||
RETRIES="$5"
|
||||
RETRIES_INTERVAL="$6"
|
||||
OUTPUT_FILE="$7"
|
||||
|
||||
# Find port ready to use
|
||||
|
||||
port=10000
|
||||
isfree=$(netstat -tapln | grep $port)
|
||||
|
||||
while [[ -n "$isfree" ]]; do
|
||||
port=$((port + 1))
|
||||
isfree=$(netstat -tapln | grep $port)
|
||||
done
|
||||
|
||||
for i in $(seq $RETRIES); do
|
||||
kubectl port-forward -n "$MAKO_STUB_NAMESPACE" "$MAKO_STUB_POD_NAME" $port:$MAKO_STUB_PORT &
|
||||
PORT_FORWARD_PID=$!
|
||||
|
||||
sleep 10
|
||||
|
||||
curl --connect-timeout $TIMEOUT "http://localhost:$port/results" > $OUTPUT_FILE
|
||||
curl_exit_status=$?
|
||||
|
||||
kill $PORT_FORWARD_PID
|
||||
wait $PORT_FORWARD_PID 2>/dev/null
|
||||
|
||||
if [ 0 -eq $curl_exit_status ]; then
|
||||
exit 0
|
||||
else
|
||||
sleep $RETRIES_INTERVAL
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
exit 1
|
|
@ -106,10 +106,11 @@ func NewDurableSendingConnection(target string, logger *zap.SugaredLogger) *Mana
|
|||
// go func() {for range messageChan {}}
|
||||
func NewDurableConnection(target string, messageChan chan []byte, logger *zap.SugaredLogger) *ManagedConnection {
|
||||
websocketConnectionFactory := func() (rawConnection, error) {
|
||||
dialer := &websocket.Dialer{
|
||||
HandshakeTimeout: 3 * time.Second,
|
||||
}
|
||||
dialer := websocket.DefaultDialer
|
||||
conn, _, err := dialer.Dial(target, nil)
|
||||
if err != nil {
|
||||
logger.Errorw("Websocket connection could not be established", zap.Error(err))
|
||||
}
|
||||
return conn, err
|
||||
}
|
||||
|
||||
|
|
|
@ -426,9 +426,7 @@ function start_knative_monitoring() {
|
|||
# mentioned in
|
||||
# https://github.com/knative/serving/blob/4202efc0dc12052edc0630515b101cbf8068a609/config/monitoring/tracing/zipkin/100-zipkin.yaml#L21
|
||||
kubectl create namespace istio-system 2>/dev/null
|
||||
echo "Installing Monitoring CRDs from $1"
|
||||
kubectl apply --selector knative.dev/crd-install=true -f "$1" || return 1
|
||||
echo "Installing the rest of monitoring components from $1"
|
||||
echo "Installing Monitoring from $1"
|
||||
kubectl apply -f "$1" || return 1
|
||||
wait_until_pods_running knative-monitoring || return 1
|
||||
wait_until_pods_running istio-system || return 1
|
||||
|
|
Loading…
Reference in New Issue