diff --git a/eventhandler_test.go b/eventhandler_test.go index 8d1c6ca..9f32fad 100644 --- a/eventhandler_test.go +++ b/eventhandler_test.go @@ -6,8 +6,8 @@ import ( "io/ioutil" "testing" - keptnlib "github.com/keptn/go-utils/pkg/lib" keptn "github.com/keptn/go-utils/pkg/lib/keptn" + keptnv2 "github.com/keptn/go-utils/pkg/lib/v0_2_0" cloudevents "github.com/cloudevents/sdk-go/v2" // make sure to use v2 cloudevents here ) @@ -15,7 +15,7 @@ import ( /** * loads a cloud event from the passed test json file and initializes a keptn object with it */ -func initializeTestObjects(eventFileName string) (*keptnlib.Keptn, *cloudevents.Event, error) { +func initializeTestObjects(eventFileName string) (*keptnv2.Keptn, *cloudevents.Event, error) { // load sample event eventFile, err := ioutil.ReadFile(eventFileName) if err != nil { @@ -30,208 +30,111 @@ func initializeTestObjects(eventFileName string) (*keptnlib.Keptn, *cloudevents. var keptnOptions = keptn.KeptnOpts{} keptnOptions.UseLocalFileSystem = true - myKeptn, err := keptnlib.NewKeptn(incomingEvent, keptnOptions) + myKeptn, err := keptnv2.NewKeptn(incomingEvent, keptnOptions) return myKeptn, incomingEvent, err } -// Handles ConfigureMonitoringEventType = "sh.keptn.event.monitoring.configure" -func TestHandleConfigureMonitoringEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/configure-monitoring.json") - if err != nil { - t.Error(err) - return - } - - specificEvent := &keptnlib.ConfigureMonitoringEventData{} - err = incomingEvent.DataAs(specificEvent) - if err != nil { - t.Errorf("Error getting keptn event data") - } - - err = HandleConfigureMonitoringEvent(myKeptn, *incomingEvent, specificEvent) - if err != nil { - t.Errorf("Error: " + err.Error()) - } -} - -// -// Handles ConfigurationChangeEventType = "sh.keptn.event.configuration.change" -// TODO: add in your handler code -// -func TestHandleConfigurationChangeEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/configuration-change.json") - if err != nil { - t.Error(err) - return - } - - specificEvent := &keptnlib.ConfigurationChangeEventData{} - err = incomingEvent.DataAs(specificEvent) - if err != nil { - t.Errorf("Error getting keptn event data") - } - - err = HandleConfigurationChangeEvent(myKeptn, *incomingEvent, specificEvent) - if err != nil { - t.Errorf("Error: " + err.Error()) - } -} - -// -// Handles DeploymentFinishedEventType = "sh.keptn.events.deployment-finished" -// TODO: add in your handler code -// -func TestHandleDeploymentFinishedEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/deployment-finished.json") - if err != nil { - t.Error(err) - return - } - - specificEvent := &keptnlib.DeploymentFinishedEventData{} - err = incomingEvent.DataAs(specificEvent) - if err != nil { - t.Errorf("Error getting keptn event data") - } - - err = HandleDeploymentFinishedEvent(myKeptn, *incomingEvent, specificEvent) - if err != nil { - t.Errorf("Error: " + err.Error()) - } -} - -// -// Handles TestsFinishedEventType = "sh.keptn.events.tests-finished" -// TODO: add in your handler code -// -func TestHandleTestsFinishedEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/tests-finished.json") - if err != nil { - t.Error(err) - return - } - - specificEvent := &keptnlib.TestsFinishedEventData{} - err = incomingEvent.DataAs(specificEvent) - if err != nil { - t.Errorf("Error getting keptn event data") - } - - err = HandleTestsFinishedEvent(myKeptn, *incomingEvent, specificEvent) - if err != nil { - t.Errorf("Error: " + err.Error()) - } -} - -// -// Handles EvaluationDoneEventType = "sh.keptn.events.evaluation-done" -// TODO: add in your handler code -// -func TestHandleStartEvaluationEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/start-evaluation.json") +// Tests HandleActionTriggeredEvent +// TODO: Add your test-code +func TestHandleActionTriggeredEvent(t *testing.T) { + myKeptn, incomingEvent, err := initializeTestObjects("test-events/action.triggered.json") if err != nil { t.Error(err) return } - specificEvent := &keptnlib.StartEvaluationEventData{} + specificEvent := &keptnv2.ActionTriggeredEventData{} err = incomingEvent.DataAs(specificEvent) if err != nil { t.Errorf("Error getting keptn event data") } - err = HandleStartEvaluationEvent(myKeptn, *incomingEvent, specificEvent) + err = HandleActionTriggeredEvent(myKeptn, *incomingEvent, specificEvent) if err != nil { t.Errorf("Error: " + err.Error()) } } -// -// Handles DeploymentFinishedEventType = "sh.keptn.events.deployment-finished" -// TODO: add in your handler code -// -func TestHandleEvaluationDoneEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/evaluation-done.json") +// Tests HandleDeploymentTriggeredEvent +// TODO: Add your test-code +func TestHandleDeploymentTriggeredEvent(t *testing.T) { + myKeptn, incomingEvent, err := initializeTestObjects("test-events/evaluation.triggered.json") if err != nil { t.Error(err) return } - specificEvent := &keptnlib.EvaluationDoneEventData{} + specificEvent := &keptnv2.DeploymentTriggeredEventData{} err = incomingEvent.DataAs(specificEvent) if err != nil { t.Errorf("Error getting keptn event data") } - err = HandleEvaluationDoneEvent(myKeptn, *incomingEvent, specificEvent) + err = HandleDeploymentTriggeredEvent(myKeptn, *incomingEvent, specificEvent) if err != nil { t.Errorf("Error: " + err.Error()) } } -// Tests the InternalGetSLIEvent Handler -func TestHandleInternalGetSLIEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/get-sli.json") +// Tests HandleEvaluationTriggeredEvent +// TODO: Add your test-code +func TestHandleEvaluationTriggeredEvent(t *testing.T) { + myKeptn, incomingEvent, err := initializeTestObjects("test-events/evaluation.triggered.json") if err != nil { t.Error(err) return } - specificEvent := &keptnlib.InternalGetSLIEventData{} + specificEvent := &keptnv2.EvaluationTriggeredEventData{} err = incomingEvent.DataAs(specificEvent) if err != nil { t.Errorf("Error getting keptn event data") } - err = HandleInternalGetSLIEvent(myKeptn, *incomingEvent, specificEvent) + err = HandleEvaluationTriggeredEvent(myKeptn, *incomingEvent, specificEvent) if err != nil { t.Errorf("Error: " + err.Error()) } } -// -// Handles ProblemOpenEventType = "sh.keptn.event.problem.open" -// Handles ProblemEventType = "sh.keptn.events.problem" -// TODO: add in your handler code -// -func TestHandleProblemEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/problem.json") +// Tests the HandleGetSliTriggeredEvent Handler +// TODO: Add your test-code +func TestHandleGetSliTriggered(t *testing.T) { + myKeptn, incomingEvent, err := initializeTestObjects("test-events/get-sli.triggered.json") if err != nil { t.Error(err) return } - specificEvent := &keptnlib.ProblemEventData{} + specificEvent := &keptnv2.GetSLITriggeredEventData{} err = incomingEvent.DataAs(specificEvent) if err != nil { t.Errorf("Error getting keptn event data") } - err = HandleProblemEvent(myKeptn, *incomingEvent, specificEvent) + err = HandleGetSliTriggeredEvent(myKeptn, *incomingEvent, specificEvent) if err != nil { t.Errorf("Error: " + err.Error()) } } -// -// Handles ActionTriggeredEventType = "sh.keptn.event.action.triggered" -// TODO: add in your handler code -// -func TestHandleActionTriggeredEvent(t *testing.T) { - myKeptn, incomingEvent, err := initializeTestObjects("test-events/action-triggered.json") +// Tests the HandleReleaseTriggeredEvent Handler +// TODO: Add your test-code +func TestHandleReleaseTriggeredEvent(t *testing.T) { + myKeptn, incomingEvent, err := initializeTestObjects("test-events/release.triggered.json") if err != nil { t.Error(err) return } - specificEvent := &keptnlib.ActionTriggeredEventData{} + specificEvent := &keptnv2.ReleaseTriggeredEventData{} err = incomingEvent.DataAs(specificEvent) if err != nil { t.Errorf("Error getting keptn event data") } - err = HandleActionTriggeredEvent(myKeptn, *incomingEvent, specificEvent) + err = HandleReleaseTriggeredEvent(myKeptn, *incomingEvent, specificEvent) if err != nil { t.Errorf("Error: " + err.Error()) } diff --git a/eventhandlers.go b/eventhandlers.go index f2c62b5..e0835e3 100644 --- a/eventhandlers.go +++ b/eventhandlers.go @@ -23,9 +23,9 @@ func GenericLogKeptnCloudEventHandler(myKeptn *keptnv2.Keptn, incomingEvent clou return nil } -// OldHandleConfigureMonitoringTriggeredEvent handles old configure-monitoring events +// OldHandleConfigureMonitoringEvent handles old configure-monitoring events // TODO: add in your handler code -func OldHandleConfigureMonitoringTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptn.ConfigureMonitoringEventData) error { +func OldHandleConfigureMonitoringEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptn.ConfigureMonitoringEventData) error { log.Printf("Handling old configure-monitoring Event: %s", incomingEvent.Context.GetID()) return nil @@ -55,6 +55,14 @@ func HandleTestTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents. return nil } +// HandleApprovalTriggeredEvent handles approval.triggered events +// TODO: add in your handler code +func HandleApprovalTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.ApprovalTriggeredEventData) error { + log.Printf("Handling approval.triggered Event: %s", incomingEvent.Context.GetID()) + + return nil +} + // HandleEvaluationTriggeredEvent handles evaluation.triggered events // TODO: add in your handler code func HandleEvaluationTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.EvaluationTriggeredEventData) error { @@ -63,7 +71,24 @@ func HandleEvaluationTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloude return nil } +// HandleReleaseTriggeredEvent handles release.triggered events +// TODO: add in your handler code +func HandleReleaseTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.ReleaseTriggeredEventData) error { + log.Printf("Handling release.triggered Event: %s", incomingEvent.Context.GetID()) + + return nil +} + +// HandleRemediationTriggeredEvent handles remediation.triggered events +// TODO: add in your handler code +func HandleRemediationTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.RemediationTriggeredEventData) error { + log.Printf("Handling remediation.triggered Event: %s", incomingEvent.Context.GetID()) + + return nil +} + // sendGetSliFinishedCloudEvent is a helper function to send a get-sli.finished event +// ToDo: This will need to be refactored once https://github.com/keptn/keptn/issues/2913 is ready func sendGetSliFinishedCloudEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.GetSLITriggeredEventData, status keptnv2.StatusType, result keptnv2.ResultType, message string) error { log.Printf("Sending getSli Finished Cloud Event with status=%s and result=%s back to Keptn (%s)", status, result, message) @@ -82,9 +107,10 @@ func sendGetSliFinishedCloudEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudeve return SendEvent(myKeptn, finishedEvent, incomingEvent) } -// HandleGetSliEvent handles get-sli events +// HandleGetSliTriggeredEvent handles get-sli.triggered events if SLIProvider == keptn-service-template-go +// This function acts as an example showing how to handle get-sli events by sending .started and .finished events // TODO: adapt handler code to your needs -func HandleGetSliEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.GetSLITriggeredEventData) error { +func HandleGetSliTriggeredEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, data *keptnv2.GetSLITriggeredEventData) error { log.Printf("Handling get-sli.triggered Event: %s", incomingEvent.Context.GetID()) // Step 1 - Do we need to do something? @@ -96,6 +122,7 @@ func HandleGetSliEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, // Step 2 - Send out a get-sli.started CloudEvent // The get-sli.started cloud-event is new since Keptn 0.8.0 and is required for the task to start + // ToDo: This will need to be refactored once https://github.com/keptn/keptn/issues/2913 is ready getSliStartedData := keptnv2.GetSLIStartedEventData{} getSliStartedData.EventData = data.EventData @@ -126,6 +153,8 @@ func HandleGetSliEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, sliFile := "keptn-service-template-go/sli.yaml" sliConfigFileContent, err := myKeptn.GetKeptnResource(sliFile) + // FYI you do not need to "fail" if sli.yaml is missing, you can also assume smart defaults like we do + // in keptn-contrib/dynatrace-service and keptn-contrib/prometheus-service if err != nil { // failed to fetch sli config file errMsg := fmt.Sprintf("Failed to fetch SLI file %s from config repo: %s", sliFile, err.Error()) @@ -154,6 +183,7 @@ func HandleGetSliEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, labels["Link to Data Source"] = "https://mydatasource/myquery?testRun=" + testRunID // Step 8 - Build get-sli.finished event data + // ToDo: This will need to be refactored once https://github.com/keptn/keptn/issues/2913 is ready getSliFinishedEventData := keptnv2.GetSLIFinishedEventData{ EventData: keptnv2.EventData{ Project: data.Project, @@ -174,12 +204,12 @@ func HandleGetSliEvent(myKeptn *keptnv2.Keptn, incomingEvent cloudevents.Event, }, } - // Step 8 - Convert To CloudEvent + // Step 9 - Convert To CloudEvent finishedEvent := cloudevents.NewEvent() finishedEvent.SetType(keptnv2.GetFinishedEventType(keptnv2.GetSLITaskName)) finishedEvent.SetData(cloudevents.ApplicationJSON, getSliFinishedEventData) - // Step 9 - send action.finished CloudEvent back to Keptn + // Step 10 - send action.finished CloudEvent back to Keptn return SendEvent(myKeptn, finishedEvent, incomingEvent) } diff --git a/main.go b/main.go index 0fe18d0..c2ec4ca 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,7 @@ type envConfig struct { const ServiceName = "keptn-service-template-go" // SendEvent sends a cloud event +// ToDo: Once https://github.com/keptn/keptn/issues/2911 is resolved, we can refactor this function func SendEvent(myKeptn *keptnv2.Keptn, event cloudevents.Event, incomingEvent cloudevents.Event) error { log.Printf("Sending CloudEvent back to Keptn: %s %s", event.Type(), event.Context.GetID()) // set source of CloudEvent @@ -87,6 +88,7 @@ func parseKeptnCloudEventPayload(event cloudevents.Event, data interface{}) erro */ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error { // create keptn handler + log.Printf("Initializing Keptn Handler") myKeptn, err := keptnv2.NewKeptn(&event, keptnOptions) if err != nil { return errors.New("Could not create Keptn Handler: " + err.Error()) @@ -177,10 +179,8 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.ProjectCreateFinishedEventData{} parseKeptnCloudEventPayload(event, eventData) - // Post-handler for deployment.finished Cloud Events (e.g., modify helm-chart, ...) - - break - + // Just log this event + return GenericLogKeptnCloudEventHandler(myKeptn, event, eventData) // ------------------------------------------------------- // sh.keptn.event.service.create - Note: This is due to change case keptnv2.GetStartedEventType(keptnv2.ServiceCreateTaskName): // sh.keptn.event.service.create.started @@ -201,9 +201,8 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.ServiceCreateFinishedEventData{} parseKeptnCloudEventPayload(event, eventData) - // Post-handler for deployment.finished Cloud Events (e.g., modify helm-chart, ...) - - break + // Just log this event + return GenericLogKeptnCloudEventHandler(myKeptn, event, eventData) // ------------------------------------------------------- // sh.keptn.event.approval @@ -213,7 +212,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.ApprovalTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - break + return HandleApprovalTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.ApprovalTaskName): // sh.keptn.event.approval.started log.Printf("Processing Approval.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -243,7 +242,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.DeploymentTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - break + return HandleDeploymentTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.DeploymentTaskName): // sh.keptn.event.deployment.started log.Printf("Processing Deployment.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -254,14 +253,6 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error // Just log this event return GenericLogKeptnCloudEventHandler(myKeptn, event, eventData) - case keptnv2.GetStatusChangedEventType(keptnv2.DeploymentTaskName): // sh.keptn.event.deployment.status.changed - log.Printf("Processing Deployment.Started Event") - // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to - // notify an external service (e.g., for logging purposes). - - // Todo: ? - - break case keptnv2.GetFinishedEventType(keptnv2.DeploymentTaskName): // sh.keptn.event.deployment.finished log.Printf("Processing Deployment.Finished Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -281,7 +272,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.TestTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - break + return HandleTestTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.TestTaskName): // sh.keptn.event.test.started log.Printf("Processing Test.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -292,14 +283,6 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error // Just log this event return GenericLogKeptnCloudEventHandler(myKeptn, event, eventData) - case keptnv2.GetStatusChangedEventType(keptnv2.TestTaskName): // sh.keptn.event.test.status.changed - log.Printf("Processing Test.Started Event") - // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to - // notify an external service (e.g., for logging purposes). - - // Todo ? - - break case keptnv2.GetFinishedEventType(keptnv2.TestTaskName): // sh.keptn.event.test.finished log.Printf("Processing Test.Finished Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -319,7 +302,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.EvaluationTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - break + return HandleEvaluationTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.EvaluationTaskName): // sh.keptn.event.evaluation.started log.Printf("Processing Evaluation.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -349,9 +332,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.ReleaseTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - // ToDo ? - - break + return HandleReleaseTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.ReleaseTaskName): // sh.keptn.event.release.started log.Printf("Processing Release.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -385,16 +366,13 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error // ------------------------------------------------------- // sh.keptn.event.remediation - // ToDo: Replace "remediation" with keptnv2.RemediationTaskName once this PR has been merged: https://github.com/keptn/go-utils/pull/230 case keptnv2.GetTriggeredEventType(keptnv2.RemediationTaskName): // sh.keptn.event.remediation.triggered log.Printf("Processing Remediation.Triggered Event") eventData := &keptnv2.RemediationTriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - // ToDo ? - - break + return HandleRemediationTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.RemediationTaskName): // sh.keptn.event.remediation.started log.Printf("Processing Remediation.Started Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to @@ -406,7 +384,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error // Just log this event return GenericLogKeptnCloudEventHandler(myKeptn, event, eventData) case keptnv2.GetStatusChangedEventType(keptnv2.RemediationTaskName): // sh.keptn.event.remediation.status.changed - log.Printf("Processing Remediation.Started Event") + log.Printf("Processing Remediation.Status.Changed Event") // Please note: Processing .started, .status.changed and .finished events is only recommended when you want to // notify an external service (e.g., for logging purposes). @@ -484,7 +462,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error eventData := &keptnv2.GetSLITriggeredEventData{} parseKeptnCloudEventPayload(event, eventData) - return HandleGetSliEvent(myKeptn, event, eventData) + return HandleGetSliTriggeredEvent(myKeptn, event, eventData) case keptnv2.GetStartedEventType(keptnv2.GetSLITaskName): // sh.keptn.event.get-sli.started log.Printf("Processing Get-SLI.Started Event") @@ -512,7 +490,7 @@ func processKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error parseKeptnCloudEventPayload(event, eventData) // Handle old configure-monitoring event - return OldHandleConfigureMonitoringTriggeredEvent(myKeptn, event, eventData) + return OldHandleConfigureMonitoringEvent(myKeptn, event, eventData) case keptnv2.GetTriggeredEventType(keptnv2.ConfigureMonitoringTaskName): // sh.keptn.event.configure-monitoring.triggered log.Printf("Processing configure-monitoring.Triggered Event") @@ -613,8 +591,11 @@ func _main(args []string, env envConfig) int { ctx := context.Background() ctx = cloudevents.WithEncodingStructured(ctx) + log.Printf("Creating new http handler") + // configure http server to receive cloudevents p, err := cloudevents.NewHTTP(cloudevents.WithPath(env.Path), cloudevents.WithPort(env.Port)) + if err != nil { log.Fatalf("failed to create client, %v", err) } @@ -622,6 +603,8 @@ func _main(args []string, env envConfig) int { if err != nil { log.Fatalf("failed to create client, %v", err) } + + log.Printf("Starting receiver") log.Fatal(c.StartReceiver(ctx, processKeptnCloudEvent)) return 0 diff --git a/test-events/action-triggered.json b/test-events/action-triggered.json deleted file mode 100644 index d6ff46e..0000000 --- a/test-events/action-triggered.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "sh.keptn.event.action.triggered", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "contenttype": "application/json", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "action": { - "name": "Toggle feature flag", - "action": "featuretoggle", - "description": "Toggle feature flag PromotionCampaign from ON to OFF.", - "value": { - "PromotionCampaign": "off" - } - }, - "problem": { - - }, - "project": "sockshop", - "stage": "production", - "service": "carts" - } -} \ No newline at end of file diff --git a/test-events/action.triggered.json b/test-events/action.triggered.json new file mode 100644 index 0000000..08897aa --- /dev/null +++ b/test-events/action.triggered.json @@ -0,0 +1,30 @@ +{ + "type": "sh.keptn.event.action.triggered", + "specversion": "1.0", + "source": "test-events", + "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79b", + "time": "2019-06-07T07:02:15.64489Z", + "contenttype": "application/json", + "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc50i", + "data": { + "project": "sockshop", + "stage": "dev", + "service": "carts", + "labels": { + "testId": "4711", + "buildId": "build-17", + "owner": "JohnDoe" + }, + "status": "succeeded", + "result": "pass", + + "action": { + "name": "my action name", + "action": "action-xyz", + "description": "so something as defined in remediation.yaml", + "value" : "1" + }, + "problem": { + } + } + } \ No newline at end of file diff --git a/test-events/configuration-change.http b/test-events/configuration-change.http deleted file mode 100644 index 2091f01..0000000 --- a/test-events/configuration-change.http +++ /dev/null @@ -1,37 +0,0 @@ -# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or -# paste cURL into the file and request will be converted to HTTP Request format. -# -# Following HTTP Request Live Templates are available: -# * 'gtrp' and 'gtr' create a GET request with or without query parameters; -# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; -# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); - -POST http://localhost:8080/ -Accept: application/json -Cache-Control: no-cache -Content-Type: application/cloudevents+json - -{ - "type": "sh.keptn.event.configuration.change", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "valuesCanary": { - "image": "docker.io/keptnexamples/carts:0.10.1" - }, - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - } -} - -### \ No newline at end of file diff --git a/test-events/configuration-change.json b/test-events/configuration-change.json deleted file mode 100644 index 803cd7e..0000000 --- a/test-events/configuration-change.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "sh.keptn.event.configuration.change", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "valuesCanary": { - "image": "docker.io/keptnexamples/carts:0.10.1" - }, - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - } -} \ No newline at end of file diff --git a/test-events/configure-monitoring.json b/test-events/configure-monitoring.json deleted file mode 100644 index 1604c51..0000000 --- a/test-events/configure-monitoring.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "contenttype": "application/json", - "data": { - "eventContext": null, - "project": "sockshop", - "service": "carts", - "type": "dynatrace" - }, - "id": "19b54fff-050e-42ed-bc4b-86112e1e65ba", - "source": "test-event", - "specversion": "0.2", - "time": "2020-10-01T12:07:24.240Z", - "type": "sh.keptn.event.monitoring.configure", - "shkeptncontext": "00688c77-a1db-4319-8210-540d7e745a3b" -} \ No newline at end of file diff --git a/test-events/deployment-finished.http b/test-events/deployment-finished.http deleted file mode 100644 index 8552b26..0000000 --- a/test-events/deployment-finished.http +++ /dev/null @@ -1,39 +0,0 @@ -# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or -# paste cURL into the file and request will be converted to HTTP Request format. -# -# Following HTTP Request Live Templates are available: -# * 'gtrp' and 'gtr' create a GET request with or without query parameters; -# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; -# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); - -POST http://localhost:8080/ -Accept: application/json -Cache-Control: no-cache -Content-Type: application/cloudevents+json - -{ - "type": "sh.keptn.events.deployment-finished", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "testStrategy": "performance", - "deploymentStrategy": "direct", - "tag": "0.10.1", - "image": "docker.io/keptnexamples/carts", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - }, - "deploymentURILocal": "http://carts.sockshop-staging.svc.cluster.local", - "deploymentURIPublic": "https://carts.sockshop-staging.my-domain.com" - } -} -### diff --git a/test-events/deployment-finished.json b/test-events/deployment-finished.json deleted file mode 100644 index 0636dc4..0000000 --- a/test-events/deployment-finished.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "sh.keptn.events.deployment-finished", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "testStrategy": "performance", - "deploymentStrategy": "direct", - "tag": "0.10.1", - "image": "docker.io/keptnexamples/carts", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - }, - "deploymentURILocal": "http://carts.sockshop-staging.svc.cluster.local", - "deploymentURIPublic": "https://carts.sockshop-staging.my-domain.com" - } -} \ No newline at end of file diff --git a/test-events/deployment.triggered.json b/test-events/deployment.triggered.json new file mode 100644 index 0000000..3a4205b --- /dev/null +++ b/test-events/deployment.triggered.json @@ -0,0 +1,30 @@ +{ + "type": "sh.keptn.event.deployment.triggered", + "specversion": "1.0", + "source": "test-events", + "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79a", + "time": "2019-06-07T07:02:15.64489Z", + "contenttype": "application/json", + "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc50g", + "data": { + "project": "sockshop", + "stage": "dev", + "service": "carts", + "labels": { + "testId": "4711", + "buildId": "build-17", + "owner": "JohnDoe" + }, + "status": "succeeded", + "result": "pass", + + "configurationChange": { + "values": { + "image": "docker.io/keptnexamples/carts:0.11.2" + } + }, + "deployment": { + "deploymentstrategy": "blue_green_service" + } + } + } \ No newline at end of file diff --git a/test-events/evaluation-done.http b/test-events/evaluation-done.http deleted file mode 100644 index 0c613ca..0000000 --- a/test-events/evaluation-done.http +++ /dev/null @@ -1,72 +0,0 @@ -# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or -# paste cURL into the file and request will be converted to HTTP Request format. -# -# Following HTTP Request Live Templates are available: -# * 'gtrp' and 'gtr' create a GET request with or without query parameters; -# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; -# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); - -POST http://localhost:8080/ -Accept: application/json -Cache-Control: no-cache -Content-Type: application/cloudevents+json - -{ - "type": "sh.keptn.events.evaluation-done", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "data":{ - "deploymentstrategy":"direct", - "evaluationdetails":{ - "indicatorResults":[ - { - "score":0, - "status":"failed", - "targets":[ - { - "criteria":"<=800", - "targetValue":800, - "violated":true - }, - { - "criteria":"<=+10%", - "targetValue":549.1967956487127, - "violated":true - }, - { - "criteria":"<600", - "targetValue":600, - "violated":true - } - ], - "value":{ - "metric":"response_time_p95", - "success":true, - "value":1002.6278552658177 - } - } - ], - "result":"fail", - "score":0, - "sloFileContent":"LS0tDQpzcGVjX3ZlcnNpb246ICcxLjAnDQpjb21wYXJpc29uOg0KICBjb21wYXJlX3dpdGg6ICJzaW5nbGVfcmVzdWx0Ig0KICBpbmNsdWRlX3Jlc3VsdF93aXRoX3Njb3JlOiAicGFzcyINCiAgYWdncmVnYXRlX2Z1bmN0aW9uOiBhdmcNCm9iamVjdGl2ZXM6DQogIC0gc2xpOiByZXNwb25zZV90aW1lX3A5NQ0KICAgIHBhc3M6ICAgICAgICAjIHBhc3MgaWYgKHJlbGF0aXZlIGNoYW5nZSA8PSAxMCUgQU5EIGFic29sdXRlIHZhbHVlIGlzIDwgNTAwKQ0KICAgICAgLSBjcml0ZXJpYToNCiAgICAgICAgICAtICI8PSsxMCUiICMgcmVsYXRpdmUgdmFsdWVzIHJlcXVpcmUgYSBwcmVmaXhlZCBzaWduIChwbHVzIG9yIG1pbnVzKQ0KICAgICAgICAgIC0gIjw2MDAiICAgIyBhYnNvbHV0ZSB2YWx1ZXMgb25seSByZXF1aXJlIGEgbG9naWNhbCBvcGVyYXRvcg0KICAgIHdhcm5pbmc6ICAgICAjIGlmIHRoZSByZXNwb25zZSB0aW1lIGlzIGJlbG93IDgwMG1zLCB0aGUgcmVzdWx0IHNob3VsZCBiZSBhIHdhcm5pbmcNCiAgICAgIC0gY3JpdGVyaWE6DQogICAgICAgICAgLSAiPD04MDAiDQp0b3RhbF9zY29yZToNCiAgcGFzczogIjkwJSINCiAgd2FybmluZzogNzUl", - "timeEnd":"2019-11-18T11:29:36Z", - "timeStart":"2019-11-18T11:21:06Z" - }, - "project":"sockshop", - "result":"fail", - "service":"carts", - "stage":"dev", - "teststrategy":"performance", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - }, - "id":"1b7cd584-320e-4ef0-8522-8a817263fdab", - "time":"2019-11-18T11:30:45.340Z", - "shkeptncontext":"60077081-f902-4407-bc15-7c70be41a836" -} - -### \ No newline at end of file diff --git a/test-events/evaluation-done.json b/test-events/evaluation-done.json deleted file mode 100644 index 1e30455..0000000 --- a/test-events/evaluation-done.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "type": "sh.keptn.events.evaluation-done", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "data":{ - "deploymentstrategy":"direct", - "evaluationdetails":{ - "indicatorResults":[ - { - "score":0, - "status":"failed", - "targets":[ - { - "criteria":"<=800", - "targetValue":800, - "violated":true - }, - { - "criteria":"<=+10%", - "targetValue":549.1967956487127, - "violated":true - }, - { - "criteria":"<600", - "targetValue":600, - "violated":true - } - ], - "value":{ - "metric":"response_time_p95", - "success":true, - "value":1002.6278552658177 - } - } - ], - "result":"fail", - "score":0, - "sloFileContent":"LS0tDQpzcGVjX3ZlcnNpb246ICcxLjAnDQpjb21wYXJpc29uOg0KICBjb21wYXJlX3dpdGg6ICJzaW5nbGVfcmVzdWx0Ig0KICBpbmNsdWRlX3Jlc3VsdF93aXRoX3Njb3JlOiAicGFzcyINCiAgYWdncmVnYXRlX2Z1bmN0aW9uOiBhdmcNCm9iamVjdGl2ZXM6DQogIC0gc2xpOiByZXNwb25zZV90aW1lX3A5NQ0KICAgIHBhc3M6ICAgICAgICAjIHBhc3MgaWYgKHJlbGF0aXZlIGNoYW5nZSA8PSAxMCUgQU5EIGFic29sdXRlIHZhbHVlIGlzIDwgNTAwKQ0KICAgICAgLSBjcml0ZXJpYToNCiAgICAgICAgICAtICI8PSsxMCUiICMgcmVsYXRpdmUgdmFsdWVzIHJlcXVpcmUgYSBwcmVmaXhlZCBzaWduIChwbHVzIG9yIG1pbnVzKQ0KICAgICAgICAgIC0gIjw2MDAiICAgIyBhYnNvbHV0ZSB2YWx1ZXMgb25seSByZXF1aXJlIGEgbG9naWNhbCBvcGVyYXRvcg0KICAgIHdhcm5pbmc6ICAgICAjIGlmIHRoZSByZXNwb25zZSB0aW1lIGlzIGJlbG93IDgwMG1zLCB0aGUgcmVzdWx0IHNob3VsZCBiZSBhIHdhcm5pbmcNCiAgICAgIC0gY3JpdGVyaWE6DQogICAgICAgICAgLSAiPD04MDAiDQp0b3RhbF9zY29yZToNCiAgcGFzczogIjkwJSINCiAgd2FybmluZzogNzUl", - "timeEnd":"2019-11-18T11:29:36Z", - "timeStart":"2019-11-18T11:21:06Z" - }, - "project":"sockshop", - "result":"fail", - "service":"carts", - "stage":"dev", - "teststrategy":"performance", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - }, - "id":"1b7cd584-320e-4ef0-8522-8a817263fdab", - "time":"2019-11-18T11:30:45.340Z", - "shkeptncontext":"60077081-f902-4407-bc15-7c70be41a836" -} \ No newline at end of file diff --git a/test-events/evaluation.triggered.json b/test-events/evaluation.triggered.json new file mode 100644 index 0000000..e009eb6 --- /dev/null +++ b/test-events/evaluation.triggered.json @@ -0,0 +1,28 @@ +{ + "data": { + "deployment": { + "deploymentNames": null + }, + "evaluation": { + "end": "2021-01-15T15:09:45.000Z", + "start": "2021-01-15T15:04:45.000Z" + }, + "labels": null, + "message": "", + "project": "sockshop", + "result": "", + "service": "carts", + "stage": "staging", + "status": "", + "test": { + "end": "", + "start": "" + } + }, + "id": "5afa758e-697c-4496-8deb-4d7cc1c93967", + "source": "test-events", + "specversion": "1.0", + "time": "2021-01-15T15:09:46.006Z", + "type": "sh.keptn.event.evaluation.triggered", + "shkeptncontext": "da7aec34-78c4-4182-a2c8-51eb88f5871d" + } \ No newline at end of file diff --git a/test-events/get-sli.http b/test-events/get-sli.http deleted file mode 100644 index 5d3ff7a..0000000 --- a/test-events/get-sli.http +++ /dev/null @@ -1,43 +0,0 @@ -# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or -# paste cURL into the file and request will be converted to HTTP Request format. -# -# Following HTTP Request Live Templates are available: -# * 'gtrp' and 'gtr' create a GET request with or without query parameters; -# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; -# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); - -POST http://localhost:8080/ -Accept: application/json -Cache-Control: no-cache -Content-Type: application/cloudevents+json - -{ - "type": "sh.keptn.internal.event.get-sli", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "data": { - "customFilters": [ - ], - "deploymentstrategy": "direct", - "end": "2019-11-19T09:26:53Z", - "indicators": [ - "response_time_p95" - ], - "project": "sockshop", - "service": "carts", - "sliProvider": "dynatrace", - "stage": "dev", - "start": "2019-11-19T09:18:14Z", - "teststrategy": "performance", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - }, - "id": "432b41e2-e50e-4d55-a4ca-0076df5b0b29", - "time": "2019-11-19T09:26:54.282Z", - "shkeptncontext": "cc42042e-9d25-48cb-a0df-ad8c2e30b6d7" -} -### diff --git a/test-events/get-sli.json b/test-events/get-sli.json deleted file mode 100644 index 35ef080..0000000 --- a/test-events/get-sli.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "type": "sh.keptn.internal.event.get-sli", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "data": { - "customFilters": [ - { - "key":"filterKey", - "value":"filterValue" - } - ], - "deploymentstrategy": "direct", - "end": "2019-11-19T09:26:53Z", - "indicators": [ - "sli_1", - "sli_2" - ], - "project": "sockshop", - "service": "carts", - "sliProvider": "keptn-service-template-go", - "stage": "dev", - "start": "2019-11-19T09:18:14Z", - "teststrategy": "performance", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - } - }, - "id": "432b41e2-e50e-4d55-a4ca-0076df5b0b29", - "time": "2019-11-19T09:26:54.282Z", - "shkeptncontext": "cc42042e-9d25-48cb-a0df-ad8c2e30b6d7" - } \ No newline at end of file diff --git a/test-events/get-sli.triggered.json b/test-events/get-sli.triggered.json new file mode 100644 index 0000000..f32b2e7 --- /dev/null +++ b/test-events/get-sli.triggered.json @@ -0,0 +1,27 @@ +{ + "data": { + "get-sli": { + "customFilters": [], + "end": "2021-01-15T15:09:45.000Z", + "indicators": [ + "response_time_p95", + "some_other_metric" + ], + "sliProvider": "keptn-service-template-go", + "start": "2021-01-15T15:04:45.000Z" + }, + "labels": null, + "message": "", + "project": "sockshop", + "result": "", + "service": "carts", + "stage": "staging", + "status": "" + }, + "id": "409539ae-c0b9-436e-abc6-c257292e28ff", + "source": "test-events", + "specversion": "1.0", + "time": "2021-01-15T15:09:46.144Z", + "type": "sh.keptn.event.get-sli.triggered", + "shkeptncontext": "da7aec34-78c4-4182-a2c8-51eb88f5871d" + } \ No newline at end of file diff --git a/test-events/problem.json b/test-events/problem.json deleted file mode 100644 index f625709..0000000 --- a/test-events/problem.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "contenttype": "application/json", - "data": { - "ImpactedEntity": "Response time degradation on Web request service simplenode.dev.direct", - "PID": "5771906213902575546", - "ProblemDetails": { - "displayName": "546", - "endTime": -1, - "hasRootCause": true, - "id": "5771906213902575546_1600356960000V2", - "impactLevel": "SERVICE", - "severityLevel": "PERFORMANCE", - "startTime": 1600357260000, - "status": "OPEN" - }, - "ProblemID": "546", - "ProblemTitle": "Response time degradation", - "ProblemURL": "https://youralertingtools/problemdetails;pid=5771906213902575546_1600356960000V2", - "State": "OPEN", - "labels": { - "Problem URL": "https://youralertingtools/problemdetails;pid=5771906213902575546_1600356960000V2" - }, - "project": "keptn07project", - "service": "simplenode", - "stage": "dev" - }, - "id": "950ec6c6-8f29-4774-83ae-98cbc92f5fb3", - "source": "test-event", - "specversion": "0.2", - "time": "2020-09-17T15:44:16.031Z", - "type": "sh.keptn.event.problem.open", - "shkeptncontext": "35373731-3930-4632-b133-393032353735" - } \ No newline at end of file diff --git a/test-events/release.triggered.json b/test-events/release.triggered.json new file mode 100644 index 0000000..28234f4 --- /dev/null +++ b/test-events/release.triggered.json @@ -0,0 +1,25 @@ +{ + "type": "sh.keptn.event.release.triggered", + "specversion": "1.0", + "source": "test-events", + "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79b", + "time": "2019-06-07T07:02:15.64489Z", + "contenttype": "application/json", + "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc50h", + "data": { + "project": "sockshop", + "stage": "dev", + "service": "carts", + "labels": { + "testId": "4711", + "buildId": "build-17", + "owner": "JohnDoe" + }, + "status": "succeeded", + "result": "pass", + + "deployment": { + "deploymentstrategy": "blue_green_service" + } + } + } \ No newline at end of file diff --git a/test-events/send-test-events.http b/test-events/send-test-events.http new file mode 100644 index 0000000..1d1a24b --- /dev/null +++ b/test-events/send-test-events.http @@ -0,0 +1,56 @@ +# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or +# paste cURL into the file and request will be converted to HTTP Request format. +# +# Following HTTP Request Live Templates are available: +# * 'gtrp' and 'gtr' create a GET request with or without query parameters; +# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; +# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); + +# send service.create.finished test-event +POST http://localhost:8080/ +Accept: application/json +Cache-Control: no-cache +Content-Type: application/cloudevents+json + +< ./service.create.finished.json +### + +# send action.triggered test-event +POST http://localhost:8080/ +Accept: application/json +Cache-Control: no-cache +Content-Type: application/cloudevents+json + +< ./action.triggered.json + +### + +# send deployment.triggered test-event +POST http://localhost:8080/ +Accept: application/json +Cache-Control: no-cache +Content-Type: application/cloudevents+json + +< ./deployment.triggered.json + +### + +# send evaluation.triggered test-event +POST http://localhost:8080/ +Accept: application/json +Cache-Control: no-cache +Content-Type: application/cloudevents+json + +< ./evaluation.triggered.json + +### + +# send get-sli.triggered test-event +POST http://localhost:8080/ +Accept: application/json +Cache-Control: no-cache +Content-Type: application/cloudevents+json + +< ./get-sli.triggered.json + +### \ No newline at end of file diff --git a/test-events/service.create.finished.json b/test-events/service.create.finished.json new file mode 100644 index 0000000..dc59670 --- /dev/null +++ b/test-events/service.create.finished.json @@ -0,0 +1,24 @@ +{ + "type": "sh.keptn.event.service.create.finished", + "specversion": "1.0", + "source": "test-events", + "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", + "time": "2019-06-07T07:02:15.64489Z", + "contenttype": "application/json", + "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc50f", + "data": { + "project": "sockshop", + "service": "carts", + "labels": { + "testId": "4711", + "buildId": "build-17", + "owner": "JohnDoe" + }, + "status": "succeeded", + "result": "pass", + + "helm": { + "chart": "H4sIFAAAAAAA/ykAK2FIUjBjSE02THk5NWIzVjBkUzVpWlM5Nk9WVjZNV2xqYW5keVRRbz1IZWxtAOxYS2/jNhDOWb9i4Mu2B8uUH7sLAXsIHHc33dgxHCdAURQGI41jNpTIkpSxRur/XlAvy5adFGgeCOq5OJoXOdTMx08JqDK61V9QZdwVjfjJCwghhHzsdtNfQsjuL/HaH0+8zieP9Hrtttc5IV67QzonQF5iM7uSaEPVCfnPa+0W906ESnaDSjMR+7D0nBB1oJg06fMpfEMeQWCbA+ZCgUa1ZAFC2jROTCP087+XRQ7iei5x3rqqo/xbyeZ/SXmC+qUA4Kn5b3vt3fnvdXrH+X8NYRG9Qx9CEdyjcplo3aM0Mf6gkeSoW2l7+MT1PNdzFErOAtoXSWx88Bwn9fUdAKnEnxgYH7QI7vVCSAdAmywzLu1DhhwFXACEKLlYRWgzhUxhYN76JP6fks2/wUhyalC3Nu/l+dDgifnv2mHfnv9et0OO8/8a0mw2wamSACqlbi09557FoQ9nZTs4ERoaUkPtvFevfi0xsLocHbQPDw/g3mQ3ShUyYL1OYUFRg3crGwKgBOcsvruWITWYqQAi+uM6pkvKOL3l6ANJ9WYl0YdJNSAFFo6BESqLjagJFhf0FrkuklEpN6hT9HnuXVQEuS/fityJLVXufXKLKkaD2gJmdhaVmlNUdAuulBZ9KJbF2tDY4mLjkQTNmm0zpbBeNx5ZIBCRFHGKslSyRxwlVaYp5vs2koP7EytFNKZ3GDZvVz58t3GP+JZs8eEBftKSMwMNv1Eum95JP7szD/6GEOc04QYaKTyZRnGeRddZCURsKItRla+uudWhxUbyu65aYaraqizVjBPOx4KzYOXD+XwkzFihtkNQeElh78XysVhvYYwslem1aEQguA/T/riiLzc8Fsr48Jl8JqUV42U979l01r++ml4OZ+PJZTVTStx8aOQn+sWWln3M5QMN6zUoXLLSOkGOVKM7yZWZQ6qza235jGhkDwfSPpjlffDlkQbJPfPWrXtuerrwtCRhj5/JXkvutWn3uuuBUShObnx5NhudDge7Z/aLEpFfUQLMGfJwgvNtba4fU7PwoVEghmuT1xc7G4wvLn8bDkbTl1gzQ6ffP2wq/vBHfQ/9y9H09Hw0mMzOh6dfa3t4qv2LNN8H4+nIdtuvg/70QJKs0fImOZTiarpnF89w+lrSYM8ryBcdTG7O+/uKTxGhHnY9uhicXn1LAweT2fXkYk+snW6/1UpiOx0LN/9thrhsUck2STlbYoxaj5W4xWpBNsFXNNs1yrS41gIpN4ttSx0dAFjMDKP8DDldXWEg4lD78LHqIVExEZY2r2ozLEKRmI2xVxoV0pC9x21rkagAdXV7nEXM6N1eCmRi8xIS7RgijIRa+dAm3c9DVjEq/CtBfSBT73Aij7S7Q/Ye/g2yy/9zhH7WfwU8+f3/aZf/dz+R4/f/q0iN/5fU/yrrBGeLJdeIv1VmzLzPE21QnVt6ktEja6sxowIdsocaQTJU3aHZ4kUlxc9oeoWUv/XhHeUoRznKO5Z/AgAA///9mYwrABwAAA==" + } + } + } \ No newline at end of file diff --git a/test-events/start-evaluation.json b/test-events/start-evaluation.json deleted file mode 100644 index c381ac8..0000000 --- a/test-events/start-evaluation.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "contenttype": "application/json", - "data": { - "end": "2020-09-27T21:59:35.813Z", - "eventContext": null, - "image": "Keptn Testing", - "labels": { - "buildId": "49" - }, - "project": "sockshop", - "service": "carts", - "stage": "dev", - "start": "2020-09-27T21:49:35.676Z", - "tag": "49", - "teststrategy": "manual" - }, - "id": "ace59102-8c44-4462-992c-4b3f8a0a287b", - "source": "test-event", - "specversion": "0.2", - "time": "2020-09-27T22:00:36.309Z", - "type": "sh.keptn.event.start-evaluation", - "shkeptncontext": "b4e6564f-cd5c-4b25-875b-9e13605aa4a3" - } \ No newline at end of file diff --git a/test-events/tests-finished.http b/test-events/tests-finished.http deleted file mode 100644 index 4ea3cca..0000000 --- a/test-events/tests-finished.http +++ /dev/null @@ -1,39 +0,0 @@ -# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or -# paste cURL into the file and request will be converted to HTTP Request format. -# -# Following HTTP Request Live Templates are available: -# * 'gtrp' and 'gtr' create a GET request with or without query parameters; -# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; -# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); - -POST http://localhost:8080/ -Accept: application/json -Cache-Control: no-cache -Content-Type: application/cloudevents+json - -{ - "type": "sh.keptn.events.tests-finished", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "testStrategy": "performance", - "deploymentStrategy": "direct", - "start": "2019-09-01 12:00:00", - "end": "2019-09-01 12:05:00", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - }, - "result": "pass" - } -} - -### \ No newline at end of file diff --git a/test-events/tests-finished.json b/test-events/tests-finished.json deleted file mode 100644 index e40d228..0000000 --- a/test-events/tests-finished.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "sh.keptn.events.tests-finished", - "contenttype": "application/json", - "specversion": "0.2", - "source": "test-event", - "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d", - "time": "2019-06-07T07:02:15.64489Z", - "shkeptncontext": "08735340-6f9e-4b32-97ff-3b6c292bc509", - "data": { - "project": "sockshop", - "stage": "dev", - "service": "carts", - "testStrategy": "performance", - "deploymentStrategy": "direct", - "start": "2019-09-01 12:00:00", - "end": "2019-09-01 12:05:00", - "labels": { - "testid": "12345", - "buildId": "build17", - "runby": "JohnDoe" - }, - "result": "pass" - } -} \ No newline at end of file