Unverified Commit 1144d835 authored by Rafał Augustyniak's avatar Rafał Augustyniak Committed by GitHub
Browse files

experimentation: reintroduce experimentation endpoint (#1205)

* Revert "Revert "experimentation: add endpoint that returns existing experiment if needed (#1188)" (#1204)"
parent 3b9b5eba
yarn12211 CDPATH-edge-case FixCordonNotes GA4 RHF add-an-option-to-select-environment add-capacity-info add-list-pr-gh-api add-origin add-pod-details add-primary-keys add-redis-frontend add-refresh-method add-stateful-fields add-tabledetails-notes add-width-prop-to-wizard addCaseInsensitiveAutocomplete addOverwriteFlag addSgTimeout addTimeoutForSG adding-chaos-blogpost allIcons api-passthrough-module appProviderRewrite attempt-pure-css-wrap auditAPI auditBE auditFE autoSubmit autoSubmitResolvers autocomplete-clear-value autocompleteFix aws-multi-account aws-multi-account-final-cutover aws-multi-account-gen-clients aws-multi-account-protos base64GH blogNits callbackToSetIndex card-hook-interface cardUpdates caseInsens1 catalog-config-extension catalog-ql-patch cfgExtends changeGridLines chaos_server-fault-enable-greater-precision chartTests chipMigration clearMocks clickAutocomplete codecov colorsFile commitsViaComparison compose-duplicate-test configurable-zap-namespace custom-title-logo customHookForTimelinePleaseWork darkModeTest1 dash-data-flow dashLayout dashLoadedCheck datetimevalid ddb-fe ddb-panic-fix ddb-refactor ddb-refactor-endpoint ddb-response-proto ddb-scale-factor-fix ddb-updategsicapacity ddb-updatetable deletePodLocationNotes deployments-table describe-pod dev-req-check-tool dialogCSS direct-client disableAuditForListPods display-termination-reason-every-time-it-is-set docshousekeeping document-and-update-api dotenv downloadConfigEnvoy dschaller-patch-1 dschaller-patch-2 dschaller-patch-3 dynamodb-panic-fix dynamodb-status-chips dynamodb-update-more-logs dynamodb-wz-1 emojiSupport enable-partial-failures-for-pods eneralize-runtime-keys-generation-feature-branch envoy-cp-update envoyTriageViaK8sDash errorBoundaryLocation eslintdocs events-api expSimplification experimentation-docs exportEmotionThings expose-k8s-clientsets featureFlagFrontend feedbackMaxLength field-redaction first-of-type-fix firstgogogo fix-audit-redact fix-authn-redirect-logic fix-autocomplete-project-catalog fix-github-app-auth-refresh fix-homedir-copy fix-list-pod fix-topo-cache-shutdown-panic fixAlignOfIcons fixConfigTypes fixDASHSpacing fixDashSpacingPart1 fixwarning frontend-autocomplete-patch frontend-catalog-navigate-patch frontend-highlight-parent frontend-project-selector-patch frontend-warning-extension gcp-0.10.3 generalize-runtime-keys-generation generalize-runtime-keys-generation-feature-branch generalize-runtime-keys-generation-server-faults-plugins get-logs ghrl glangci-test go-1-18 go-1.19-in-ci go-actions-1-18 go-github-v38 golangci goworkspace graphql group-item-prefix gtag header-adjustments hooks-first-in-select hooksForAutoRefresh horizontalExpansion housekeeping-yaml housekeepingclutch hydrateAllFunc iam-custompolicy-sim iconButton iconButtonColors inputTransformers issue-refresh-token jest-coverage-fix jg/github jslaughter-patch-1 k8s-dash k8sAction k8sDashAutosubmit kind-upgrade license-update linkCSS lintHooks list-services listOptionsChange load-state-error log-redact-k8s-protos lowercaseAutocomplete main matv5 matv5-base matv5-core matv5-core-input matv5-core-layout matv5-joined matv5-wizard matv5-workflows metrics-blog metricsAPI metricsProtos mikecutalo-patch-1 minimistClutch moarTests moartests mockProjects mui-5-upgrade mui-v5 mui-v5-codemods mui-v5-core mui5 muiv5-upgrade murki-patch-1 navigation networkTests nodeNameInCordonNode nonexistantProjects nps-anytime nps-collector nps-custom-patch openSourceReactMarkdownPane otherEventTimes override-old-state-with-new override-search paperMinWidth pass-config-as-proto-message pattern-extract pcDefaultProjects pcResetState pcSearch pcSubtext pd-info-project-proto persistProjects pgv-0.6.0 pod-events preflight-check-script project-api-mocks project-api-optional-compute-deps project-api-protos project-catalog project-catalog-config-patch project-catalog-config-skeleton project-catalog-details project-catalog-scaffold project-proto-deps project-selector-autocomplete project-selector-testing project404 projectSelectorState proto-get-endpoint protoForDeploys protoc-3.17 proxy-mod-impl qLinks1 qLinksF qLinksForProjSelector queryParamPreserve quickLinks1 quicklinks1 rdis-decouple-protos react-17 reactHookForm read-through-the-provider redis-3-rtds refresh refreshDropdown registrarEmptyRoutes relativeCfgDir reloadIntervalForProjSelector remove-unused-testconfig remove-utm-params removeBottomFeedbackButton removeIcon renderTestTimeseriesChart renovate-patch renovate/actions-setup-node-3.x renovate/actions-stale-4.x renovate/actions-stale-6.x renovate/actions-upload-artifact-3.x renovate/babel-monorepo renovate/cypress-10.x renovate/cypress-7.x renovate/cypress-8.x renovate/cypress-9.x renovate/docker-build-push-action-2.x renovate/docker-build-push-action-3.x renovate/docker-login-action-2.x renovate/docker-setup-buildx-action-2.x renovate/docusaurus-monorepo renovate/esbuild-0.x renovate/eslint-config-airbnb-19.x renovate/eslint-plugin-jest-25.x renovate/eslint-plugin-jest-26.x renovate/eslint-plugin-prettier-4.x renovate/font-awesome renovate/github.com-aws-aws-sdk-go-v2-1.x renovate/github.com-aws-aws-sdk-go-v2-config-1.x renovate/github.com-aws-aws-sdk-go-v2-credentials-1.x renovate/github.com-aws-aws-sdk-go-v2-service-autoscaling-1.x renovate/github.com-aws-aws-sdk-go-v2-service-ec2-1.x renovate/github.com-aws-aws-sdk-go-v2-service-kinesis-1.x renovate/github.com-aws-aws-sdk-go-v2-service-s3-1.x renovate/github.com-aws-smithy-go-1.x renovate/github.com-bradleyfalzon-ghinstallation-2.x renovate/github.com-bufbuild-buf-0.x renovate/github.com-bufbuild-buf-1.x renovate/github.com-coreos-go-oidc-v3-3.x renovate/github.com-envoyproxy-go-control-plane-0.x renovate/github.com-envoyproxy-protoc-gen-validate-0.x renovate/github.com-fullstorydev-grpcurl-1.x renovate/github.com-go-git-go-billy-v5-5.x renovate/github.com-go-git-go-git-v5-5.x renovate/github.com-gogo-status-1.x renovate/github.com-golang-migrate-migrate-v4-4.x renovate/github.com-google-go-github-v34-35.x renovate/github.com-google-go-github-v35-35.x renovate/github.com-google-go-github-v36-37.x renovate/github.com-google-go-github-v37-38.x renovate/github.com-grpc-ecosystem-grpc-gateway-v2-2.x renovate/github.com-jhump-protoreflect-1.x renovate/github.com-lib-pq-1.x renovate/github.com-masterminds-squirrel-1.x renovate/github.com-shurcool-githubv4-digest renovate/github.com-shurcool-graphql-digest renovate/github.com-slack-go-slack-0.x renovate/github.com-stretchr-testify-1.x renovate/github.com-uber-go-tally-3.x renovate/github.com-uber-go-tally-v4-4.x renovate/github.com-yoheimuta-go-protoparser-v4-4.x renovate/go-1.x renovate/go.temporal.io-sdk-1.x renovate/go.temporal.io-sdk-contrib-tally-0.x renovate/go.uber.org-zap-1.x renovate/golang-1.x renovate/golang.org-x-net-digest renovate/google.golang.org-genproto-digest renovate/google.golang.org-grpc-1.x renovate/google.golang.org-grpc-cmd-protoc-gen-go-grpc-1.x renovate/google.golang.org-protobuf-1.x renovate/gopkg.in-square-go-jose.v2-2.x renovate/hookform-devtools-3.x renovate/hookform-devtools-4.x renovate/hookform-resolvers-2.x renovate/k8s.io-api-0.x renovate/k8s.io-apimachinery-0.x renovate/k8s.io-client-go-0.x renovate/k8s.io-utils-digest renovate/kubernetes-go renovate/lock-file-maintenance renovate/major-1-kubernetes-go renovate/major-10-definitelytyped renovate/major-10-kubernetes-go renovate/major-11-kubernetes-go renovate/major-16-definitelytyped renovate/major-17-react-monorepo renovate/major-18-definitelytyped renovate/major-18-react-monorepo renovate/major-19-eslint renovate/major-2-kubernetes-go renovate/major-27-definitelytyped renovate/major-27-unittest renovate/major-28-definitelytyped renovate/major-28-unittest renovate/major-29-definitelytyped renovate/major-3-kubernetes-go renovate/major-4-eslint renovate/major-5-typescript-eslint-monorepo renovate/major-6-font-awesome renovate/major-8-eslint renovate/major-8-remark-monorepo renovate/major-9-definitelytyped renovate/material-table-1.x renovate/material-table-2.x renovate/nivo-monorepo renovate/node-16.x renovate/node-17.x renovate/node-18.x renovate/node-19.x renovate/npm-axios-vulnerability renovate/npm-prismjs-vulnerability renovate/npm-protobufjs-vulnerability renovate/postgres-14.x renovate/postgres-15.x renovate/protobufjs-6.x renovate/react-hook-form-7.x renovate/react-hook-thunk-reducer-0.x renovate/react-scripts-5.x renovate/react-timeago-6.x renovate/react-tiny-popover-7.x renovate/webpack-4.x renovate/webpack-dev-server-3.x renovate/webpack-dev-server-4.x renovateFix replaceNivoWithRechartsForEnvoy require-UnmarshalTo require-durationpb resizeAsgValidationFix responsiveDash responsiveProjectSelector responsiveTable return-partial-errors return-status revert-2270-addCaseInsensitiveAutocomplete revert-2348-timeago-patch s3accessdebugger-oss safetyCheckForAccounts scaffold-non-wizard scaffold-update scaffoldingYarn scatterPlotTimeline scrolling-menu search-resolver-fix select-grouping select-patch selectIndex shareOnBlog shortlink-protos shortlink-scaffolding shortlink-wip singleChoiceDrawer sl-bug-fix sl-patch slowloris smonero-patch-1 sortWorkflowGroups sourcegraph-impl sourcegraph-service spacingAdjustment sperry-CreateFeedback-proto sperry-GetFeedbackQuestions-proto sperry-SubmitFeedback-API sperry-add-GetSurveys-module sperry-add-emojis sperry-add-prop sperry-autocomplete-fix-experimentations sperry-blog-post sperry-card-header sperry-card-loading-prop sperry-cardcontent-paddingprop sperry-cards-fullWidth sperry-class-setChecked sperry-collapse-bttn sperry-core-tooltip sperry-custom-header-matcher sperry-enableFeedback-prop sperry-extend-type sperry-feedback-config sperry-feedback-docs sperry-globally-enable-wizard sperry-hidden-w-icon sperry-hiddenstate sperry-incremental-dash-updates sperry-migrate-card-framework sperry-project-api-custom-projects sperry-project-links-proto sperry-project-selector sperry-project-selector-autocomplete sperry-proxy-module-host-header sperry-query-params sperry-refactor sperry-remove-npswizard-featureflag sperry-remove-state sperry-removeprojects-state sperry-resize-hpa-notes sperry-see-more-card-action sperry-slackbot-api sperry-slackbot-mod sperry-slackbot-service sperry-sort-project-names sperry-stats-prefix sperry-tooltip sperry-update-api-call sperry-update-card-header-design sperry-update-package sperry-update-protos state-hydration state-hydration-alerts state-hydration-selector state-hydration-short-links state-hydration-storage storybookDocs strictDash supportStylingOfCharts tableCSS tablecss temporal-client test-rpc-invoke tfAdornment themeProvider timeSelectorHooks timeSeriesProto timeago-component timestampInt64 todosPublic toggleButtonGroup toggleTest topology-docs topology-paginated-api-search-protos transientProps trimPrefixForAWS typescript-4.2.x typography typographyNoWrap typographyStory typographyfix update-air-tool update-buf-0.41 update-card-styling update-golangci-lint-1-42-1 update-kind-tool update-pod-status updatePodEventProto use-refresh-token userGroups validate-pattern-at-runtime vscodeProtoPaths webicon wizardOrigin workflowOrigins workflowRegistrarOverride workflowYarnMin wrapper2 wrapperForTimeSeries wrapperForTimeSeries2
No related merge requests found
Showing with 1222 additions and 307 deletions
+1222 -307
syntax = "proto3";
package clutch.chaos.experimentation.v1;
import "validate/validate.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/lyft/clutch/backend/api/chaos/experimentation/v1;experimentationv1";
// The data used as an input for experiment creation.
message CreateExperimentData {
// The unique identifier of experiment run that's created as part of the experiment creation process.
// A random run identifier is generated and assigned to the experiment if it's not provided by a caller.
// Its max length is limited to 100 characters. The identifier is supposed to be user-readable and
// URL renderable - for this reason, allowed characters are limited to English characters, digits and
// the following special characters: "-", ".", "_" and "~".
string run_id = 1;
// The experiment configuration specific to the type of experiment.
google.protobuf.Any config = 2 [ (validate.rules).any.required = true ];
// The time when the experiment should start. If not provided, defaults to 'now'. It cannot be in the past.
google.protobuf.Timestamp start_time = 3;
// The time when the experiment should end, If not provided, the experiment runs until it's manually stopped.
// If provided, it has to be after `start_time`.
google.protobuf.Timestamp end_time = 4;
}
......@@ -23,10 +23,11 @@ message Experiment {
STATUS_STOPPED = 5;
}
uint64 id = 1;
// The experiment configuration specific to the type of experiment
// An unique identifier of an experiment run.
string run_id = 1;
// The experiment configuration specific to the type of experiment.
google.protobuf.Any config = 2;
// The time when the experiment should start. If unspecified, defaults to 'now'
// The time when the experiment should start.
google.protobuf.Timestamp start_time = 3;
// The time when the experiment should end, If unspecified, the experiment runs indefinitely unless it is manually
// stopped by a user.
......
......@@ -11,7 +11,7 @@ option go_package = "github.com/lyft/clutch/backend/api/chaos/experimentation/v1
// ExperimentRunDetails frontend-renderable details of an experiment run and experiment config associated with it.
message ExperimentRunDetails {
// The unique identifier of an experiment run.
fixed64 run_id = 1;
string run_id = 1;
// The status of an experiment run.
Experiment.Status status = 2;
// The list of properties associated with the receiver that's created as a combination
......
......@@ -4,28 +4,43 @@ package clutch.chaos.experimentation.v1;
import "api/v1/annotations.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "chaos/experimentation/v1/experiment.proto";
import "chaos/experimentation/v1/create_experiment_data.proto";
import "chaos/experimentation/v1/list_view_item.proto";
import "chaos/experimentation/v1/experiment_run_details.proto";
option go_package = "github.com/lyft/clutch/backend/api/chaos/experimentation/v1;experimentationv1";
message CreateExperimentRequest {
// The experiment configuration specific to the type of experiment
google.protobuf.Any config = 1;
// The time when the experiment should start. If unspecified, defaults to 'now'
google.protobuf.Timestamp start_time = 2;
// The time when the experiment should end, If unspecified, the experiment runs indefinitely.
google.protobuf.Timestamp end_time = 3;
// The data specifying the experiment to create. See `CreateExperiment` for more details.
CreateExperimentData data = 1;
}
message CreateExperimentResponse {
// The created experiment.
Experiment experiment = 1;
}
message CreateOrGetExperimentRequest {
// The data specifying the experiment to fetch or create. See `CreateOrGetExperiment` for more details.
CreateExperimentData data = 1;
}
message CreateOrGetExperimentResponse {
enum Origin {
ORIGIN_UNSPECIFIED = 0;
ORIGIN_EXISTING = 1;
ORIGIN_NEW = 2;
}
// The created or fetched experiment that was requested by a caller. See `origin` to learn more
// about how to check whether a new experiment was created as the result of request's execution.
Experiment experiment = 1;
// The type of returned experiment - either a newly created experiment or an existing one.
Origin origin = 2;
}
message GetExperimentsRequest {
enum Status {
STATUS_UNSPECIFIED = 0;
......@@ -46,7 +61,7 @@ message CancelExperimentRunRequest {
pattern : "{id}"
};
uint64 id = 1;
string id = 1;
}
message CancelExperimentRunResponse {
......@@ -65,7 +80,7 @@ message GetExperimentRunDetailsRequest {
pattern : "{id}"
};
uint64 id = 1;
string id = 1;
}
message GetExperimentRunDetailsResponse {
......@@ -74,6 +89,8 @@ message GetExperimentRunDetailsResponse {
// Simple CRUD API for experiments
service ExperimentsAPI {
// Create a new experiment using the provided experiment data. It fails if an experiment run
// with the provided run identifier already exists. See `CreateExperimentData` for more details.
rpc CreateExperiment(CreateExperimentRequest) returns (CreateExperimentResponse) {
option (google.api.http) = {
post : "/v1/chaos/experimentation/createExperiment"
......@@ -81,6 +98,17 @@ service ExperimentsAPI {
};
option (clutch.api.v1.action).type = CREATE;
}
// Create a new experiment using the provided experiment data. It succeeds even if an experiment run
// with the provided run identifier already exists. In this case, the rest of request's payload is ignored
// and existing experiment with a matching run identifier is returned. See `CreateExperimentData` for more
// details.
rpc CreateOrGetExperiment(CreateOrGetExperimentRequest) returns (CreateOrGetExperimentResponse) {
option (google.api.http) = {
post : "/v1/chaos/experimentation/createOrGetExperiment"
body : "*"
};
option (clutch.api.v1.action).type = CREATE;
}
rpc CancelExperimentRun(CancelExperimentRunRequest) returns (CancelExperimentRunResponse) {
option (google.api.http) = {
post : "/v1/chaos/experimentation/cancelExperimentRun"
......
......@@ -9,7 +9,7 @@ option go_package = "github.com/lyft/clutch/backend/api/chaos/experimentation/v1
// ListViewItem an abstraction for a list item.
message ListViewItem {
// The unique identifier of a list item.
uint64 id = 1;
string id = 1;
// The properties map.
PropertiesMap properties = 2;
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.14.0
// source: chaos/experimentation/v1/create_experiment_data.proto
package experimentationv1
import (
_ "github.com/envoyproxy/protoc-gen-validate/validate"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// The data used as an input for experiment creation.
type CreateExperimentData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The unique identifier of experiment run that's created as part of the experiment creation process.
// A random run identifier is generated and assigned to the experiment if it's not provided by a caller.
// Its max length is limited to 100 characters. The identifier is supposed to be user-readable and
// URL renderable - for this reason, allowed characters are limited to English characters, digits and
// the following special characters: "-", ".", "_" and "~".
RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"`
// The experiment configuration specific to the type of experiment.
Config *anypb.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
// The time when the experiment should start. If not provided, defaults to 'now'. It cannot be in the past.
StartTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
// The time when the experiment should end, If not provided, the experiment runs until it's manually stopped.
// If provided, it has to be after `start_time`.
EndTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
}
func (x *CreateExperimentData) Reset() {
*x = CreateExperimentData{}
if protoimpl.UnsafeEnabled {
mi := &file_chaos_experimentation_v1_create_experiment_data_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateExperimentData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateExperimentData) ProtoMessage() {}
func (x *CreateExperimentData) ProtoReflect() protoreflect.Message {
mi := &file_chaos_experimentation_v1_create_experiment_data_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateExperimentData.ProtoReflect.Descriptor instead.
func (*CreateExperimentData) Descriptor() ([]byte, []int) {
return file_chaos_experimentation_v1_create_experiment_data_proto_rawDescGZIP(), []int{0}
}
func (x *CreateExperimentData) GetRunId() string {
if x != nil {
return x.RunId
}
return ""
}
func (x *CreateExperimentData) GetConfig() *anypb.Any {
if x != nil {
return x.Config
}
return nil
}
func (x *CreateExperimentData) GetStartTime() *timestamppb.Timestamp {
if x != nil {
return x.StartTime
}
return nil
}
func (x *CreateExperimentData) GetEndTime() *timestamppb.Timestamp {
if x != nil {
return x.EndTime
}
return nil
}
var File_chaos_experimentation_v1_create_experiment_data_proto protoreflect.FileDescriptor
var file_chaos_experimentation_v1_create_experiment_data_proto_rawDesc = []byte{
0x0a, 0x35, 0x63, 0x68, 0x61, 0x6f, 0x73, 0x2f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65,
0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74,
0x65, 0x5f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74,
0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x63, 0x6c, 0x75, 0x74, 0x63, 0x68, 0x2e,
0x63, 0x68, 0x61, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61,
0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd7, 0x01,
0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65,
0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x72, 0x75, 0x6e, 0x49, 0x64, 0x12, 0x36, 0x0a,
0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x41, 0x6e, 0x79, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x06, 0x63,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74,
0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65,
0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07,
0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x79, 0x66, 0x74, 0x2f, 0x63, 0x6c, 0x75, 0x74, 0x63,
0x68, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x68,
0x61, 0x6f, 0x73, 0x2f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_chaos_experimentation_v1_create_experiment_data_proto_rawDescOnce sync.Once
file_chaos_experimentation_v1_create_experiment_data_proto_rawDescData = file_chaos_experimentation_v1_create_experiment_data_proto_rawDesc
)
func file_chaos_experimentation_v1_create_experiment_data_proto_rawDescGZIP() []byte {
file_chaos_experimentation_v1_create_experiment_data_proto_rawDescOnce.Do(func() {
file_chaos_experimentation_v1_create_experiment_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_chaos_experimentation_v1_create_experiment_data_proto_rawDescData)
})
return file_chaos_experimentation_v1_create_experiment_data_proto_rawDescData
}
var file_chaos_experimentation_v1_create_experiment_data_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_chaos_experimentation_v1_create_experiment_data_proto_goTypes = []interface{}{
(*CreateExperimentData)(nil), // 0: clutch.chaos.experimentation.v1.CreateExperimentData
(*anypb.Any)(nil), // 1: google.protobuf.Any
(*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp
}
var file_chaos_experimentation_v1_create_experiment_data_proto_depIdxs = []int32{
1, // 0: clutch.chaos.experimentation.v1.CreateExperimentData.config:type_name -> google.protobuf.Any
2, // 1: clutch.chaos.experimentation.v1.CreateExperimentData.start_time:type_name -> google.protobuf.Timestamp
2, // 2: clutch.chaos.experimentation.v1.CreateExperimentData.end_time:type_name -> google.protobuf.Timestamp
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_chaos_experimentation_v1_create_experiment_data_proto_init() }
func file_chaos_experimentation_v1_create_experiment_data_proto_init() {
if File_chaos_experimentation_v1_create_experiment_data_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_chaos_experimentation_v1_create_experiment_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateExperimentData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_chaos_experimentation_v1_create_experiment_data_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_chaos_experimentation_v1_create_experiment_data_proto_goTypes,
DependencyIndexes: file_chaos_experimentation_v1_create_experiment_data_proto_depIdxs,
MessageInfos: file_chaos_experimentation_v1_create_experiment_data_proto_msgTypes,
}.Build()
File_chaos_experimentation_v1_create_experiment_data_proto = out.File
file_chaos_experimentation_v1_create_experiment_data_proto_rawDesc = nil
file_chaos_experimentation_v1_create_experiment_data_proto_goTypes = nil
file_chaos_experimentation_v1_create_experiment_data_proto_depIdxs = nil
}
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: chaos/experimentation/v1/create_experiment_data.proto
package experimentationv1
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"strings"
"time"
"unicode/utf8"
"github.com/golang/protobuf/ptypes"
)
// ensure the imports are used
var (
_ = bytes.MinRead
_ = errors.New("")
_ = fmt.Print
_ = utf8.UTFMax
_ = (*regexp.Regexp)(nil)
_ = (*strings.Reader)(nil)
_ = net.IPv4len
_ = time.Duration(0)
_ = (*url.URL)(nil)
_ = (*mail.Address)(nil)
_ = ptypes.DynamicAny{}
)
// define the regex for a UUID once up-front
var _create_experiment_data_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
// Validate checks the field values on CreateExperimentData with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *CreateExperimentData) Validate() error {
if m == nil {
return nil
}
// no validation rules for RunId
if m.GetConfig() == nil {
return CreateExperimentDataValidationError{
field: "Config",
reason: "value is required",
}
}
if a := m.GetConfig(); a != nil {
}
if v, ok := interface{}(m.GetStartTime()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateExperimentDataValidationError{
field: "StartTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
if v, ok := interface{}(m.GetEndTime()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateExperimentDataValidationError{
field: "EndTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// CreateExperimentDataValidationError is the validation error returned by
// CreateExperimentData.Validate if the designated constraints aren't met.
type CreateExperimentDataValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CreateExperimentDataValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CreateExperimentDataValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CreateExperimentDataValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CreateExperimentDataValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CreateExperimentDataValidationError) ErrorName() string {
return "CreateExperimentDataValidationError"
}
// Error satisfies the builtin error interface
func (e CreateExperimentDataValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCreateExperimentData.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CreateExperimentDataValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CreateExperimentDataValidationError{}
......@@ -91,10 +91,11 @@ type Experiment struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// The experiment configuration specific to the type of experiment
// An unique identifier of an experiment run.
RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"`
// The experiment configuration specific to the type of experiment.
Config *anypb.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
// The time when the experiment should start. If unspecified, defaults to 'now'
// The time when the experiment should start.
StartTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
// The time when the experiment should end, If unspecified, the experiment runs indefinitely unless it is manually
// stopped by a user.
......@@ -133,11 +134,11 @@ func (*Experiment) Descriptor() ([]byte, []int) {
return file_chaos_experimentation_v1_experiment_proto_rawDescGZIP(), []int{0}
}
func (x *Experiment) GetId() uint64 {
func (x *Experiment) GetRunId() string {
if x != nil {
return x.Id
return x.RunId
}
return 0
return ""
}
func (x *Experiment) GetConfig() *anypb.Any {
......@@ -172,33 +173,34 @@ var file_chaos_experimentation_v1_experiment_proto_rawDesc = []byte{
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e,
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x02, 0x0a, 0x0a, 0x45, 0x78, 0x70,
0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x63,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74,
0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcf, 0x02, 0x0a, 0x0a, 0x45, 0x78, 0x70,
0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x75, 0x6e, 0x5f, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x72, 0x75, 0x6e, 0x49, 0x64, 0x12, 0x2c,
0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0a,
0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74,
0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74,
0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65,
0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07,
0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x89, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74,
0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53,
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54,
0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x43, 0x48, 0x45, 0x44, 0x55, 0x4c, 0x45, 0x44, 0x10, 0x01,
0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49,
0x4e, 0x47, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43,
0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54,
0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12,
0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45,
0x44, 0x10, 0x05, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x6c, 0x79, 0x66, 0x74, 0x2f, 0x63, 0x6c, 0x75, 0x74, 0x63, 0x68, 0x2f, 0x62, 0x61,
0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x68, 0x61, 0x6f, 0x73, 0x2f,
0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f,
0x76, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x89,
0x01, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41,
0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10,
0x00, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x43, 0x48, 0x45,
0x44, 0x55, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55,
0x53, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x53,
0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10,
0x03, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x41, 0x4e, 0x43,
0x45, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,
0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x05, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x79, 0x66, 0x74, 0x2f, 0x63, 0x6c,
0x75, 0x74, 0x63, 0x68, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x63, 0x68, 0x61, 0x6f, 0x73, 0x2f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69,
0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
......
......@@ -43,7 +43,7 @@ func (m *Experiment) Validate() error {
return nil
}
// no validation rules for Id
// no validation rules for RunId
if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
......
......@@ -28,7 +28,7 @@ type ExperimentRunDetails struct {
unknownFields protoimpl.UnknownFields
// The unique identifier of an experiment run.
RunId uint64 `protobuf:"fixed64,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"`
RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"`
// The status of an experiment run.
Status Experiment_Status `protobuf:"varint,2,opt,name=status,proto3,enum=clutch.chaos.experimentation.v1.Experiment_Status" json:"status,omitempty"`
// The list of properties associated with the receiver that's created as a combination
......@@ -70,11 +70,11 @@ func (*ExperimentRunDetails) Descriptor() ([]byte, []int) {
return file_chaos_experimentation_v1_experiment_run_details_proto_rawDescGZIP(), []int{0}
}
func (x *ExperimentRunDetails) GetRunId() uint64 {
func (x *ExperimentRunDetails) GetRunId() string {
if x != nil {
return x.RunId
}
return 0
return ""
}
func (x *ExperimentRunDetails) GetStatus() Experiment_Status {
......@@ -116,7 +116,7 @@ var file_chaos_experimentation_v1_experiment_run_details_proto_rawDesc = []byte{
0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf8, 0x01, 0x0a, 0x14, 0x45, 0x78,
0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x75, 0x6e, 0x44, 0x65, 0x74, 0x61, 0x69,
0x6c, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x06, 0x52, 0x05, 0x72, 0x75, 0x6e, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x06, 0x73, 0x74, 0x61,
0x28, 0x09, 0x52, 0x05, 0x72, 0x75, 0x6e, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x06, 0x73, 0x74, 0x61,
0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x32, 0x2e, 0x63, 0x6c, 0x75, 0x74,
0x63, 0x68, 0x2e, 0x63, 0x68, 0x61, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d,
0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x65,
......
This diff is collapsed.
......@@ -65,6 +65,40 @@ func local_request_ExperimentsAPI_CreateExperiment_0(ctx context.Context, marsha
}
func request_ExperimentsAPI_CreateOrGetExperiment_0(ctx context.Context, marshaler runtime.Marshaler, client ExperimentsAPIClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateOrGetExperimentRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateOrGetExperiment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ExperimentsAPI_CreateOrGetExperiment_0(ctx context.Context, marshaler runtime.Marshaler, server ExperimentsAPIServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateOrGetExperimentRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CreateOrGetExperiment(ctx, &protoReq)
return msg, metadata, err
}
func request_ExperimentsAPI_CancelExperimentRun_0(ctx context.Context, marshaler runtime.Marshaler, client ExperimentsAPIClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CancelExperimentRunRequest
var metadata runtime.ServerMetadata
......@@ -230,6 +264,29 @@ func RegisterExperimentsAPIHandlerServer(ctx context.Context, mux *runtime.Serve
})
mux.Handle("POST", pattern_ExperimentsAPI_CreateOrGetExperiment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/clutch.chaos.experimentation.v1.ExperimentsAPI/CreateOrGetExperiment")
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ExperimentsAPI_CreateOrGetExperiment_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ExperimentsAPI_CreateOrGetExperiment_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_ExperimentsAPI_CancelExperimentRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
......@@ -383,6 +440,26 @@ func RegisterExperimentsAPIHandlerClient(ctx context.Context, mux *runtime.Serve
})
mux.Handle("POST", pattern_ExperimentsAPI_CreateOrGetExperiment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/clutch.chaos.experimentation.v1.ExperimentsAPI/CreateOrGetExperiment")
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ExperimentsAPI_CreateOrGetExperiment_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ExperimentsAPI_CreateOrGetExperiment_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_ExperimentsAPI_CancelExperimentRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
......@@ -469,6 +546,8 @@ func RegisterExperimentsAPIHandlerClient(ctx context.Context, mux *runtime.Serve
var (
pattern_ExperimentsAPI_CreateExperiment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "chaos", "experimentation", "createExperiment"}, ""))
pattern_ExperimentsAPI_CreateOrGetExperiment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "chaos", "experimentation", "createOrGetExperiment"}, ""))
pattern_ExperimentsAPI_CancelExperimentRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "chaos", "experimentation", "cancelExperimentRun"}, ""))
pattern_ExperimentsAPI_GetExperiments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "chaos", "experimentation", "getExperiments"}, ""))
......@@ -481,6 +560,8 @@ var (
var (
forward_ExperimentsAPI_CreateExperiment_0 = runtime.ForwardResponseMessage
forward_ExperimentsAPI_CreateOrGetExperiment_0 = runtime.ForwardResponseMessage
forward_ExperimentsAPI_CancelExperimentRun_0 = runtime.ForwardResponseMessage
forward_ExperimentsAPI_GetExperiments_0 = runtime.ForwardResponseMessage
......
......@@ -44,30 +44,10 @@ func (m *CreateExperimentRequest) Validate() error {
return nil
}
if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateExperimentRequestValidationError{
field: "Config",
reason: "embedded message failed validation",
cause: err,
}
}
}
if v, ok := interface{}(m.GetStartTime()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateExperimentRequestValidationError{
field: "StartTime",
reason: "embedded message failed validation",
cause: err,
}
}
}
if v, ok := interface{}(m.GetEndTime()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateExperimentRequestValidationError{
field: "EndTime",
field: "Data",
reason: "embedded message failed validation",
cause: err,
}
......@@ -210,6 +190,164 @@ var _ interface {
ErrorName() string
} = CreateExperimentResponseValidationError{}
// Validate checks the field values on CreateOrGetExperimentRequest with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *CreateOrGetExperimentRequest) Validate() error {
if m == nil {
return nil
}
if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateOrGetExperimentRequestValidationError{
field: "Data",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// CreateOrGetExperimentRequestValidationError is the validation error returned
// by CreateOrGetExperimentRequest.Validate if the designated constraints
// aren't met.
type CreateOrGetExperimentRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CreateOrGetExperimentRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CreateOrGetExperimentRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CreateOrGetExperimentRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CreateOrGetExperimentRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CreateOrGetExperimentRequestValidationError) ErrorName() string {
return "CreateOrGetExperimentRequestValidationError"
}
// Error satisfies the builtin error interface
func (e CreateOrGetExperimentRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCreateOrGetExperimentRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CreateOrGetExperimentRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CreateOrGetExperimentRequestValidationError{}
// Validate checks the field values on CreateOrGetExperimentResponse with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *CreateOrGetExperimentResponse) Validate() error {
if m == nil {
return nil
}
if v, ok := interface{}(m.GetExperiment()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CreateOrGetExperimentResponseValidationError{
field: "Experiment",
reason: "embedded message failed validation",
cause: err,
}
}
}
// no validation rules for Origin
return nil
}
// CreateOrGetExperimentResponseValidationError is the validation error
// returned by CreateOrGetExperimentResponse.Validate if the designated
// constraints aren't met.
type CreateOrGetExperimentResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CreateOrGetExperimentResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CreateOrGetExperimentResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CreateOrGetExperimentResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CreateOrGetExperimentResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CreateOrGetExperimentResponseValidationError) ErrorName() string {
return "CreateOrGetExperimentResponseValidationError"
}
// Error satisfies the builtin error interface
func (e CreateOrGetExperimentResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCreateOrGetExperimentResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CreateOrGetExperimentResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CreateOrGetExperimentResponseValidationError{}
// Validate checks the field values on GetExperimentsRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
......
......@@ -18,7 +18,14 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ExperimentsAPIClient interface {
// Create a new experiment using the provided experiment data. It fails if an experiment run
// with the provided run identifier already exists. See `CreateExperimentData` for more details.
CreateExperiment(ctx context.Context, in *CreateExperimentRequest, opts ...grpc.CallOption) (*CreateExperimentResponse, error)
// Create a new experiment using the provided experiment data. It succeeds even if an experiment run
// with the provided run identifier already exists. In this case, the rest of request's payload is ignored
// and existing experiment with a matching run identifier is returned. See `CreateExperimentData` for more
// details.
CreateOrGetExperiment(ctx context.Context, in *CreateOrGetExperimentRequest, opts ...grpc.CallOption) (*CreateOrGetExperimentResponse, error)
CancelExperimentRun(ctx context.Context, in *CancelExperimentRunRequest, opts ...grpc.CallOption) (*CancelExperimentRunResponse, error)
GetExperiments(ctx context.Context, in *GetExperimentsRequest, opts ...grpc.CallOption) (*GetExperimentsResponse, error)
GetListView(ctx context.Context, in *GetListViewRequest, opts ...grpc.CallOption) (*GetListViewResponse, error)
......@@ -42,6 +49,15 @@ func (c *experimentsAPIClient) CreateExperiment(ctx context.Context, in *CreateE
return out, nil
}
func (c *experimentsAPIClient) CreateOrGetExperiment(ctx context.Context, in *CreateOrGetExperimentRequest, opts ...grpc.CallOption) (*CreateOrGetExperimentResponse, error) {
out := new(CreateOrGetExperimentResponse)
err := c.cc.Invoke(ctx, "/clutch.chaos.experimentation.v1.ExperimentsAPI/CreateOrGetExperiment", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *experimentsAPIClient) CancelExperimentRun(ctx context.Context, in *CancelExperimentRunRequest, opts ...grpc.CallOption) (*CancelExperimentRunResponse, error) {
out := new(CancelExperimentRunResponse)
err := c.cc.Invoke(ctx, "/clutch.chaos.experimentation.v1.ExperimentsAPI/CancelExperimentRun", in, out, opts...)
......@@ -82,7 +98,14 @@ func (c *experimentsAPIClient) GetExperimentRunDetails(ctx context.Context, in *
// All implementations should embed UnimplementedExperimentsAPIServer
// for forward compatibility
type ExperimentsAPIServer interface {
// Create a new experiment using the provided experiment data. It fails if an experiment run
// with the provided run identifier already exists. See `CreateExperimentData` for more details.
CreateExperiment(context.Context, *CreateExperimentRequest) (*CreateExperimentResponse, error)
// Create a new experiment using the provided experiment data. It succeeds even if an experiment run
// with the provided run identifier already exists. In this case, the rest of request's payload is ignored
// and existing experiment with a matching run identifier is returned. See `CreateExperimentData` for more
// details.
CreateOrGetExperiment(context.Context, *CreateOrGetExperimentRequest) (*CreateOrGetExperimentResponse, error)
CancelExperimentRun(context.Context, *CancelExperimentRunRequest) (*CancelExperimentRunResponse, error)
GetExperiments(context.Context, *GetExperimentsRequest) (*GetExperimentsResponse, error)
GetListView(context.Context, *GetListViewRequest) (*GetListViewResponse, error)
......@@ -96,6 +119,9 @@ type UnimplementedExperimentsAPIServer struct {
func (UnimplementedExperimentsAPIServer) CreateExperiment(context.Context, *CreateExperimentRequest) (*CreateExperimentResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateExperiment not implemented")
}
func (UnimplementedExperimentsAPIServer) CreateOrGetExperiment(context.Context, *CreateOrGetExperimentRequest) (*CreateOrGetExperimentResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateOrGetExperiment not implemented")
}
func (UnimplementedExperimentsAPIServer) CancelExperimentRun(context.Context, *CancelExperimentRunRequest) (*CancelExperimentRunResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CancelExperimentRun not implemented")
}
......@@ -138,6 +164,24 @@ func _ExperimentsAPI_CreateExperiment_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
func _ExperimentsAPI_CreateOrGetExperiment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateOrGetExperimentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ExperimentsAPIServer).CreateOrGetExperiment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/clutch.chaos.experimentation.v1.ExperimentsAPI/CreateOrGetExperiment",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ExperimentsAPIServer).CreateOrGetExperiment(ctx, req.(*CreateOrGetExperimentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ExperimentsAPI_CancelExperimentRun_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CancelExperimentRunRequest)
if err := dec(in); err != nil {
......@@ -221,6 +265,10 @@ var ExperimentsAPI_ServiceDesc = grpc.ServiceDesc{
MethodName: "CreateExperiment",
Handler: _ExperimentsAPI_CreateExperiment_Handler,
},
{
MethodName: "CreateOrGetExperiment",
Handler: _ExperimentsAPI_CreateOrGetExperiment_Handler,
},
{
MethodName: "CancelExperimentRun",
Handler: _ExperimentsAPI_CancelExperimentRun_Handler,
......
......@@ -27,7 +27,7 @@ type ListViewItem struct {
unknownFields protoimpl.UnknownFields
// The unique identifier of a list item.
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// The properties map.
Properties *PropertiesMap `protobuf:"bytes,2,opt,name=properties,proto3" json:"properties,omitempty"`
}
......@@ -64,11 +64,11 @@ func (*ListViewItem) Descriptor() ([]byte, []int) {
return file_chaos_experimentation_v1_list_view_item_proto_rawDescGZIP(), []int{0}
}
func (x *ListViewItem) GetId() uint64 {
func (x *ListViewItem) GetId() string {
if x != nil {
return x.Id
}
return 0
return ""
}
func (x *ListViewItem) GetProperties() *PropertiesMap {
......@@ -90,7 +90,7 @@ var file_chaos_experimentation_v1_list_view_item_proto_rawDesc = []byte{
0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x65,
0x72, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6e, 0x0a, 0x0c, 0x4c,
0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4e, 0x0a, 0x0a, 0x70,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4e, 0x0a, 0x0a, 0x70,
0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x2e, 0x2e, 0x63, 0x6c, 0x75, 0x74, 0x63, 0x68, 0x2e, 0x63, 0x68, 0x61, 0x6f, 0x73, 0x2e, 0x65,
0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76,
......
BEGIN;
LOCK TABLE experiment_config, experiment_run IN ACCESS EXCLUSIVE MODE;
ALTER TABLE experiment_run ALTER COLUMN "experiment_config_id" SET DATA TYPE BIGINT USING experiment_config_id::BIGINT;
ALTER TABLE experiment_run ALTER COLUMN "id" SET DATA TYPE BIGINT USING id::BIGINT;
ALTER TABLE experiment_config ALTER COLUMN "id" SET DATA TYPE BIGINT USING id::BIGINT;
COMMIT;
BEGIN;
LOCK TABLE experiment_config, experiment_run IN ACCESS EXCLUSIVE MODE;
ALTER TABLE experiment_config ALTER COLUMN "id" SET DATA TYPE varchar(100) USING id::varchar;
ALTER TABLE experiment_run ALTER COLUMN "id" SET DATA TYPE varchar(100) USING id::varchar;
ALTER TABLE experiment_run ALTER COLUMN "experiment_config_id" SET DATA TYPE varchar(100) USING experiment_config_id::varchar;
COMMIT;
......@@ -3,7 +3,6 @@ package experimentstoremock
import (
"context"
"fmt"
"time"
"github.com/golang/protobuf/ptypes/any"
"github.com/uber-go/tally"
......@@ -28,11 +27,15 @@ type getExperimentArguments struct {
ConfigType string
}
func (fs *MockStorer) CreateExperiment(ctx context.Context, config *any.Any, startTime *time.Time, endTime *time.Time) (*experimentation.Experiment, error) {
func (fs *MockStorer) CreateExperiment(ctx context.Context, es *experimentstore.ExperimentSpecification) (*experimentation.Experiment, error) {
return nil, nil
}
func (fs *MockStorer) CancelExperimentRun(ctx context.Context, id uint64, terminationReason string) error {
func (fs *MockStorer) CreateOrGetExperiment(ctx context.Context, es *experimentstore.ExperimentSpecification) (*experimentstore.CreateOrGetExperimentResult, error) {
return nil, nil
}
func (fs *MockStorer) CancelExperimentRun(ctx context.Context, runId string, reason string) error {
return nil
}
......@@ -45,7 +48,7 @@ func (fs *MockStorer) GetListView(ctx context.Context) ([]*experimentation.ListV
return nil, nil
}
func (fs *MockStorer) GetExperimentRunDetails(ctx context.Context, id uint64) (*experimentation.ExperimentRunDetails, error) {
func (fs *MockStorer) GetExperimentRunDetails(ctx context.Context, runId string) (*experimentation.ExperimentRunDetails, error) {
return nil, nil
}
......
......@@ -2,28 +2,29 @@ package experimentstoremock
import (
"context"
"strconv"
"sync"
"time"
"github.com/golang/protobuf/ptypes"
"google.golang.org/protobuf/types/known/anypb"
experimentationv1 "github.com/lyft/clutch/backend/api/chaos/experimentation/v1"
experimentation "github.com/lyft/clutch/backend/api/chaos/experimentation/v1"
"github.com/lyft/clutch/backend/service/chaos/experimentation/experimentstore"
)
type SimpleExperiment struct {
id uint64
runId string
config *anypb.Any
startTime *time.Time
startTime time.Time
stopTime *time.Time
}
func (s SimpleExperiment) toProto() *experimentationv1.Experiment {
startTime, _ := ptypes.TimestampProto(*s.startTime)
func (s *SimpleExperiment) toProto() *experimentation.Experiment {
startTime, _ := ptypes.TimestampProto(s.startTime)
endTime, _ := ptypes.TimestampProto(*s.stopTime)
return &experimentationv1.Experiment{
Id: s.id,
return &experimentation.Experiment{
RunId: s.runId,
Config: s.config,
StartTime: startTime,
EndTime: endTime,
......@@ -32,27 +33,39 @@ func (s SimpleExperiment) toProto() *experimentationv1.Experiment {
type SimpleStorer struct {
experiments []SimpleExperiment
idGenerator uint64
idGenerator int
sync.Mutex
}
func (s *SimpleStorer) CreateExperiment(ctx context.Context, config *anypb.Any, startTime *time.Time, stopTime *time.Time) (*experimentationv1.Experiment, error) {
func (s *SimpleStorer) CreateExperiment(ctx context.Context, es *experimentstore.ExperimentSpecification) (*experimentation.Experiment, error) {
s.Lock()
defer s.Unlock()
s.experiments = append(s.experiments, SimpleExperiment{id: s.idGenerator, config: config, startTime: startTime, stopTime: stopTime})
s.experiments = append(s.experiments, SimpleExperiment{runId: strconv.Itoa(s.idGenerator), config: es.Config, startTime: es.StartTime, stopTime: es.EndTime})
s.idGenerator++
return s.experiments[len(s.experiments)-1].toProto(), nil
}
func (s *SimpleStorer) CancelExperimentRun(ctx context.Context, id uint64, terminationReason string) error {
func (s *SimpleStorer) CreateOrGetExperiment(ctx context.Context, es *experimentstore.ExperimentSpecification) (*experimentstore.CreateOrGetExperimentResult, error) {
experiment, err := s.CreateExperiment(ctx, es)
if err != nil {
return nil, err
}
return &experimentstore.CreateOrGetExperimentResult{
Experiment: experiment,
Origin: experimentation.CreateOrGetExperimentResponse_ORIGIN_NEW,
}, nil
}
func (s *SimpleStorer) CancelExperimentRun(ctx context.Context, runId string, reason string) error {
s.Lock()
defer s.Unlock()
newExperiments := []SimpleExperiment{}
for _, e := range s.experiments {
if e.id == id {
if e.runId == runId {
continue
}
......@@ -63,11 +76,11 @@ func (s *SimpleStorer) CancelExperimentRun(ctx context.Context, id uint64, termi
return nil
}
func (s *SimpleStorer) GetExperiments(ctx context.Context, configType string, status experimentationv1.GetExperimentsRequest_Status) ([]*experimentationv1.Experiment, error) {
func (s *SimpleStorer) GetExperiments(ctx context.Context, configType string, status experimentation.GetExperimentsRequest_Status) ([]*experimentation.Experiment, error) {
s.Lock()
defer s.Unlock()
experiments := []*experimentationv1.Experiment{}
experiments := []*experimentation.Experiment{}
for _, e := range s.experiments {
experiments = append(experiments, e.toProto())
......@@ -75,10 +88,10 @@ func (s *SimpleStorer) GetExperiments(ctx context.Context, configType string, st
return experiments, nil
}
func (s *SimpleStorer) GetExperimentRunDetails(ctx context.Context, id uint64) (*experimentationv1.ExperimentRunDetails, error) {
func (s *SimpleStorer) GetExperimentRunDetails(ctx context.Context, runId string) (*experimentation.ExperimentRunDetails, error) {
return nil, nil
}
func (s *SimpleStorer) GetListView(ctx context.Context) ([]*experimentationv1.ListViewItem, error) {
func (s *SimpleStorer) GetListView(ctx context.Context) ([]*experimentation.ListViewItem, error) {
return nil, nil
}
func (s *SimpleStorer) RegisterTransformation(transformation experimentstore.Transformation) error {
......
......@@ -28,6 +28,7 @@ type Service struct {
storer experimentstore.Storer
logger *zap.SugaredLogger
createExperimentStat tally.Counter
createOrGetExperimentStats tally.Scope
cancelExperimentRunStat tally.Counter
getExperimentsStat tally.Counter
getListViewStat tally.Counter
......@@ -50,6 +51,7 @@ func New(_ *any.Any, logger *zap.Logger, scope tally.Scope) (module.Module, erro
storer: experimentStore,
logger: logger.Sugar(),
createExperimentStat: scope.Counter("create_experiment"),
createOrGetExperimentStats: scope.SubScope("create_or_get_experiment"),
cancelExperimentRunStat: scope.Counter("cancel_experiment_run"),
getExperimentsStat: scope.Counter("get_experiments"),
getListViewStat: scope.Counter("get_list_view"),
......@@ -66,27 +68,45 @@ func (s *Service) Register(r module.Registrar) error {
func (s *Service) CreateExperiment(ctx context.Context, req *experimentation.CreateExperimentRequest) (*experimentation.CreateExperimentResponse, error) {
s.createExperimentStat.Inc(1)
// If start time is not provided, default to starting now
now := time.Now()
startTime := &now
if req.StartTime != nil {
s := req.StartTime.AsTime()
startTime = &s
es, err := experimentstore.NewExperimentSpecification(req.Data, time.Now())
if err != nil {
return nil, err
}
// If the end time is not provided, default to no end time
var endTime *time.Time = nil
if req.EndTime != nil {
s := req.EndTime.AsTime()
endTime = &s
experiment, err := s.storer.CreateExperiment(ctx, es)
if err != nil {
return nil, err
}
experiment, err := s.storer.CreateExperiment(ctx, req.Config, startTime, endTime)
return &experimentation.CreateExperimentResponse{Experiment: experiment}, nil
}
func (s *Service) CreateOrGetExperiment(ctx context.Context, req *experimentation.CreateOrGetExperimentRequest) (*experimentation.CreateOrGetExperimentResponse, error) {
s.createOrGetExperimentStats.Counter("request").Inc(1)
es, err := experimentstore.NewExperimentSpecification(req.Data, time.Now())
if err != nil {
return nil, err
}
createOrGetExperiment, err := s.storer.CreateOrGetExperiment(ctx, es)
if err != nil {
return nil, err
}
return &experimentation.CreateExperimentResponse{Experiment: experiment}, nil
r := s.createOrGetExperimentStats.SubScope("result")
switch createOrGetExperiment.Origin {
case experimentation.CreateOrGetExperimentResponse_ORIGIN_UNSPECIFIED:
r.Counter("unspecified").Inc(1)
case experimentation.CreateOrGetExperimentResponse_ORIGIN_EXISTING:
r.Counter("get").Inc(1)
case experimentation.CreateOrGetExperimentResponse_ORIGIN_NEW:
r.Counter("create").Inc(1)
}
return &experimentation.CreateOrGetExperimentResponse{
Experiment: createOrGetExperiment.Experiment,
Origin: createOrGetExperiment.Origin,
}, nil
}
// CancelExperimentRun cancels experiment that is currently running or is scheduled to be run in the future.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment