-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an e2e test for source data transformer (#505)
Signed-off-by: Keran Yang <[email protected]>
- Loading branch information
Showing
10 changed files
with
132 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: numaflow.numaproj.io/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: event-time-filter | ||
spec: | ||
vertices: | ||
- name: in | ||
source: | ||
http: {} | ||
transformer: | ||
container: | ||
image: quay.io/numaio/numaflow-go/mapt-event-time-filter:latest | ||
- name: sink-within-2022 | ||
scale: | ||
min: 1 | ||
sink: | ||
log: {} | ||
- name: sink-after-2022 | ||
scale: | ||
min: 1 | ||
sink: | ||
log: {} | ||
- name: sink-all | ||
scale: | ||
min: 1 | ||
sink: | ||
log: {} | ||
edges: | ||
- from: in | ||
to: sink-within-2022 | ||
conditions: | ||
keyIn: | ||
- within_year_2022 | ||
- from: in | ||
to: sink-after-2022 | ||
conditions: | ||
keyIn: | ||
- after_year_2022 | ||
- from: in | ||
to: sink-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//go:build test | ||
|
||
/* | ||
Copyright 2022 The Numaproj Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package transformer_e2e | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
. "github.com/numaproj/numaflow/test/fixtures" | ||
) | ||
|
||
type TransformerSuite struct { | ||
E2ESuite | ||
} | ||
|
||
func (s *TransformerSuite) TestEventTimeFilter() { | ||
w := s.Given().Pipeline("@testdata/event-time-filter.yaml"). | ||
When(). | ||
CreatePipelineAndWait() | ||
defer w.DeletePipelineAndWait() | ||
pipelineName := "event-time-filter" | ||
|
||
// wait for all the pods to come up | ||
w.Expect().VertexPodsRunning() | ||
|
||
eventTimeBefore2022_1 := strconv.FormatInt(time.Date(2021, 4, 2, 7, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
eventTimeBefore2022_2 := strconv.FormatInt(time.Date(1998, 4, 2, 8, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
eventTimeBefore2022_3 := strconv.FormatInt(time.Date(2013, 4, 4, 7, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
|
||
eventTimeAfter2022_1 := strconv.FormatInt(time.Date(2023, 4, 2, 7, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
eventTimeAfter2022_2 := strconv.FormatInt(time.Date(2026, 4, 2, 3, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
|
||
eventTimeWithin2022_1 := strconv.FormatInt(time.Date(2022, 4, 2, 3, 4, 5, 2, time.UTC).UnixMilli(), 10) | ||
|
||
w.SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("Before2022")).WithHeader("X-Numaflow-Event-Time", eventTimeBefore2022_1)). | ||
SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("Before2022")).WithHeader("X-Numaflow-Event-Time", eventTimeBefore2022_2)). | ||
SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("Before2022")).WithHeader("X-Numaflow-Event-Time", eventTimeBefore2022_3)). | ||
SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("After2022")).WithHeader("X-Numaflow-Event-Time", eventTimeAfter2022_1)). | ||
SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("After2022")).WithHeader("X-Numaflow-Event-Time", eventTimeAfter2022_2)). | ||
SendMessageTo(pipelineName, "in", NewHttpPostRequest().WithBody([]byte("Within2022")).WithHeader("X-Numaflow-Event-Time", eventTimeWithin2022_1)) | ||
|
||
janFirst2022 := time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC) | ||
janFirst2023 := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) | ||
|
||
w.Expect(). | ||
VertexPodLogContains("sink-within-2022", fmt.Sprintf("EventTime - %d", janFirst2022.UnixMilli()), PodLogCheckOptionWithCount(1)). | ||
VertexPodLogContains("sink-after-2022", fmt.Sprintf("EventTime - %d", janFirst2023.UnixMilli()), PodLogCheckOptionWithCount(2)). | ||
VertexPodLogContains("sink-all", fmt.Sprintf("EventTime - %d", janFirst2022.UnixMilli()), PodLogCheckOptionWithCount(1)). | ||
VertexPodLogContains("sink-all", fmt.Sprintf("EventTime - %d", janFirst2023.UnixMilli()), PodLogCheckOptionWithCount(2)). | ||
VertexPodLogNotContains("sink-within-2022", fmt.Sprintf("EventTime - %d", janFirst2023.UnixMilli())). | ||
VertexPodLogNotContains("sink-after-2022", fmt.Sprintf("EventTime - %d", janFirst2022.UnixMilli())). | ||
VertexPodLogNotContains("sink-all", "Before2022"). | ||
VertexPodLogNotContains("sink-within-2022", "Before2022"). | ||
VertexPodLogNotContains("sink-after-2022", "Before2022") | ||
} | ||
|
||
func TestTransformerSuite(t *testing.T) { | ||
suite.Run(t, new(TransformerSuite)) | ||
} |