Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fix workflow run filter #5161

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions engine/api/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,16 @@ func (c *websocketClient) send(ctx context.Context, event sdk.Event) (err error)
case strings.HasPrefix(event.EventType, "sdk.EventRunWorkflow") && c.filter.Type == sdk.WebsocketFilterTypeWorkflow:
if event.ProjectKey != c.filter.ProjectKey || event.WorkflowName != c.filter.WorkflowName {
sendEvent = false
break
}
if c.filter.WorkflowRunNumber != 0 && event.WorkflowRunNum != c.filter.WorkflowRunNumber {
sendEvent = false
break
}
// WORKFLOW NODE RUN EVENT
if c.filter.WorkflowNodeRunID != 0 && event.WorkflowNodeRunID != c.filter.WorkflowNodeRunID {
sendEvent = false
break
}
sendEvent = true
default:
Expand Down
14 changes: 9 additions & 5 deletions engine/api/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,23 @@ func Test_websocketGetWorkflowEvent(t *testing.T) {
go client.WebsocketEventsListen(context.TODO(), chanMessageToSend, chanMessageReceived)

chanMessageToSend <- sdk.WebsocketFilter{
Type: sdk.WebsocketFilterTypeWorkflow,
ProjectKey: key,
WorkflowName: w.Name,
Type: sdk.WebsocketFilterTypeWorkflow,
ProjectKey: key,
WorkflowName: w.Name,
WorkflowRunNumber: 1,
}
// Waiting websocket to update filter
time.Sleep(1 * time.Second)

api.websocketBroker.messages <- sdk.Event{ProjectKey: proj.Key, WorkflowName: w.Name, EventType: "sdk.EventWorkflow"}
api.websocketBroker.messages <- sdk.Event{ProjectKey: "blabla", WorkflowName: "toto", EventType: "sdk.EventRunWorkflow", WorkflowRunNum: 1}
api.websocketBroker.messages <- sdk.Event{ProjectKey: proj.Key, WorkflowName: w.Name, EventType: "sdk.EventRunWorkflow", WorkflowRunNum: 1}
response := <-chanMessageReceived
require.Equal(t, "OK", response.Status)
require.Equal(t, response.Event.EventType, "sdk.EventWorkflow")
require.Equal(t, response.Event.EventType, "sdk.EventRunWorkflow")
require.Equal(t, response.Event.ProjectKey, proj.Key)
require.Equal(t, response.Event.WorkflowName, w.Name)

assert.Equal(t, 0, len(chanMessageReceived))
}

func Test_websocketDeconnection(t *testing.T) {
Expand Down