Skip to content

Commit e728666

Browse files
committed
Test order
Signed-off-by: joshvanl <[email protected]>
1 parent a9ba946 commit e728666

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/e2e/standalone/run_template_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func TestRunWithTemplateFile(t *testing.T) {
4747
})
4848
// These tests are dependent on run template files in ../testdata/run-template-files folder.
4949

50-
t.Run("invalid template file wrong emit metrics app run", func(t *testing.T) {
51-
runFilePath := "../testdata/run-template-files/wrong_emit_metrics_app_dapr.yaml"
50+
t.Run("valid template file", func(t *testing.T) {
51+
runFilePath := "../testdata/run-template-files/dapr.yaml"
5252
t.Cleanup(func() {
5353
// assumption in the test is that there is only one set of app and daprd logs in the logs directory.
5454
cleanUpLogs()
@@ -62,17 +62,22 @@ func TestRunWithTemplateFile(t *testing.T) {
6262
require.NoError(t, err, "run failed")
6363
// Deterministic output for template file, so we can assert line by line
6464
lines := strings.Split(output, "\n")
65-
assert.GreaterOrEqual(t, len(lines), 4, "expected at least 4 lines in output of starting two apps")
65+
assert.GreaterOrEqual(t, len(lines), 6, "expected at least 6 lines in output of starting two apps")
66+
assert.Contains(t, lines[0], "Validating config and starting app \"processor\"")
6667
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
6768
assert.Contains(t, lines[2], "Writing log files to directory")
6869
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
70+
assert.Contains(t, lines[3], "Validating config and starting app \"emit-metrics\"")
6971
assert.Contains(t, lines[4], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
7072
assert.Contains(t, lines[5], "Writing log files to directory")
7173
assert.Contains(t, lines[5], "tests/apps/emit-metrics/.dapr/logs")
7274
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
7375
appTestOutput := AppTestOutput{
7476
appID: "processor",
7577
baseLogDirPath: "../../apps/processor/.dapr/logs",
78+
appLogContents: []string{
79+
"Received metrics: {1}",
80+
},
7681
daprdLogContent: []string{
7782
"HTTP server is running on port 3510",
7883
"You're up and running! Dapr logs will appear here.",
@@ -83,19 +88,21 @@ func TestRunWithTemplateFile(t *testing.T) {
8388
appID: "emit-metrics",
8489
baseLogDirPath: "../../apps/emit-metrics/.dapr/logs",
8590
appLogContents: []string{
86-
"stat wrongappname.go: no such file or directory",
87-
"The App process exited with error code: exit status 1",
91+
"DAPR_HTTP_PORT set to 3511",
92+
"DAPR_HOST_ADD set to localhost",
93+
"Metrics with ID 1 sent",
8894
},
8995
daprdLogContent: []string{
9096
"termination signal received: shutting down",
9197
"Exited Dapr successfully",
98+
"Exited App successfully",
9299
},
93100
}
94101
assertLogOutputForRunTemplateExec(t, appTestOutput)
95102
})
96103

97-
t.Run("valid template file", func(t *testing.T) {
98-
runFilePath := "../testdata/run-template-files/dapr.yaml"
104+
t.Run("invalid template file wrong emit metrics app run", func(t *testing.T) {
105+
runFilePath := "../testdata/run-template-files/wrong_emit_metrics_app_dapr.yaml"
99106
t.Cleanup(func() {
100107
// assumption in the test is that there is only one set of app and daprd logs in the logs directory.
101108
cleanUpLogs()
@@ -109,22 +116,17 @@ func TestRunWithTemplateFile(t *testing.T) {
109116
require.NoError(t, err, "run failed")
110117
// Deterministic output for template file, so we can assert line by line
111118
lines := strings.Split(output, "\n")
112-
assert.GreaterOrEqual(t, len(lines), 6, "expected at least 6 lines in output of starting two apps")
113-
assert.Contains(t, lines[0], "Validating config and starting app \"processor\"")
119+
assert.GreaterOrEqual(t, len(lines), 4, "expected at least 4 lines in output of starting two apps")
114120
assert.Contains(t, lines[1], "Started Dapr with app id \"processor\". HTTP Port: 3510.")
115121
assert.Contains(t, lines[2], "Writing log files to directory")
116122
assert.Contains(t, lines[2], "tests/apps/processor/.dapr/logs")
117-
assert.Contains(t, lines[3], "Validating config and starting app \"emit-metrics\"")
118123
assert.Contains(t, lines[4], "Started Dapr with app id \"emit-metrics\". HTTP Port: 3511.")
119124
assert.Contains(t, lines[5], "Writing log files to directory")
120125
assert.Contains(t, lines[5], "tests/apps/emit-metrics/.dapr/logs")
121126
assert.Contains(t, output, "Received signal to stop Dapr and app processes. Shutting down Dapr and app processes.")
122127
appTestOutput := AppTestOutput{
123128
appID: "processor",
124129
baseLogDirPath: "../../apps/processor/.dapr/logs",
125-
appLogContents: []string{
126-
"Received metrics: {1}",
127-
},
128130
daprdLogContent: []string{
129131
"HTTP server is running on port 3510",
130132
"You're up and running! Dapr logs will appear here.",
@@ -135,14 +137,12 @@ func TestRunWithTemplateFile(t *testing.T) {
135137
appID: "emit-metrics",
136138
baseLogDirPath: "../../apps/emit-metrics/.dapr/logs",
137139
appLogContents: []string{
138-
"DAPR_HTTP_PORT set to 3511",
139-
"DAPR_HOST_ADD set to localhost",
140-
"Metrics with ID 1 sent",
140+
"stat wrongappname.go: no such file or directory",
141+
"The App process exited with error code: exit status 1",
141142
},
142143
daprdLogContent: []string{
143144
"termination signal received: shutting down",
144145
"Exited Dapr successfully",
145-
"Exited App successfully",
146146
},
147147
}
148148
assertLogOutputForRunTemplateExec(t, appTestOutput)

0 commit comments

Comments
 (0)