Skip to content

Commit de38192

Browse files
committed
Fix unit tests
Adds uninstall as start test funcs Increase e2e test timeout to 30m Prints output of scheduler run log Increases timeout for waiting for list output Set scheduler & placement host address to 127.0.0.1 in tests Adds error log output to scheduler cmd run tests Hard code gRPC port Skip scheduler tests in slim mode Adds registration log lines Change app port Signed-off-by: joshvanl <[email protected]>
1 parent bbfe027 commit de38192

File tree

8 files changed

+120
-42
lines changed

8 files changed

+120
-42
lines changed

.github/workflows/kind_e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
name: E2E tests for K8s (KinD)
5151
runs-on: ubuntu-latest
5252
env:
53-
DAPR_RUNTIME_PINNED_VERSION: 1.16.1-rc.3
53+
DAPR_RUNTIME_PINNED_VERSION: 1.16.1
5454
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
5555
DAPR_RUNTIME_LATEST_STABLE_VERSION:
5656
DAPR_DASHBOARD_LATEST_STABLE_VERSION:

.github/workflows/self_hosted_e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
GOARCH: ${{ matrix.target_arch }}
3939
GOPROXY: https://proxy.golang.org
4040
ARCHIVE_OUTDIR: dist/archives
41-
DAPR_RUNTIME_PINNED_VERSION: "1.16.1-rc.3"
41+
DAPR_RUNTIME_PINNED_VERSION: "1.16.1"
4242
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
4343
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
4444
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ TEST_OUTPUT_FILE ?= test_output.json
7474

7575
# Set the default timeout for tests to 10 minutes
7676
ifndef E2E_SH_TEST_TIMEOUT
77-
override E2E_SH_TEST_TIMEOUT := 10m
77+
override E2E_SH_TEST_TIMEOUT := 30m
7878
endif
7979

8080
# Use the variable H to add a header (equivalent to =>) to informational output

pkg/kubernetes/components_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestComponents(t *testing.T) {
4040
name: "List one config",
4141
configName: "",
4242
outputFormat: "",
43-
expectedOutput: " NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \n default appConfig state.redis v1 " + formattedNow + " 0s \n",
43+
expectedOutput: "NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \ndefault appConfig state.redis v1 " + formattedNow + " 0s \n",
4444
errString: "",
4545
errorExpected: false,
4646
k8sConfig: []v1alpha1.Component{
@@ -70,7 +70,7 @@ func TestComponents(t *testing.T) {
7070
name: "Filters out daprsystem",
7171
configName: "",
7272
outputFormat: "",
73-
expectedOutput: " NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \n default appConfig state.redis v1 " + formattedNow + " 0s \n",
73+
expectedOutput: "NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \ndefault appConfig state.redis v1 " + formattedNow + " 0s \n",
7474
errString: "",
7575
errorExpected: false,
7676
k8sConfig: []v1alpha1.Component{
@@ -98,7 +98,7 @@ func TestComponents(t *testing.T) {
9898
name: "Name does match",
9999
configName: "appConfig",
100100
outputFormat: "list",
101-
expectedOutput: " NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \n default appConfig state.redis v1 " + formattedNow + " 0s \n",
101+
expectedOutput: "NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \ndefault appConfig state.redis v1 " + formattedNow + " 0s \n",
102102
errString: "",
103103
errorExpected: false,
104104
k8sConfig: []v1alpha1.Component{
@@ -119,7 +119,7 @@ func TestComponents(t *testing.T) {
119119
name: "Name does not match",
120120
configName: "appConfig",
121121
outputFormat: "list",
122-
expectedOutput: " NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \n",
122+
expectedOutput: "NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE \n",
123123
errString: "",
124124
errorExpected: false,
125125
k8sConfig: []v1alpha1.Component{

pkg/kubernetes/configurations_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestConfigurations(t *testing.T) {
4141
name: "List one config",
4242
configName: "",
4343
outputFormat: "",
44-
expectedOutput: " NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \n default appConfig false false 0s " + formattedNow + " \n",
44+
expectedOutput: "NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \ndefault appConfig false false 0s " + formattedNow + " \n",
4545
errString: "",
4646
errorExpected: false,
4747
k8sConfig: []v1alpha1.Configuration{
@@ -68,7 +68,7 @@ func TestConfigurations(t *testing.T) {
6868
name: "Filters out daprsystem",
6969
configName: "",
7070
outputFormat: "",
71-
expectedOutput: " NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \n default appConfig false false 0s " + formattedNow + " \n",
71+
expectedOutput: "NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \ndefault appConfig false false 0s " + formattedNow + " \n",
7272
errString: "",
7373
errorExpected: false,
7474
k8sConfig: []v1alpha1.Configuration{
@@ -94,7 +94,7 @@ func TestConfigurations(t *testing.T) {
9494
name: "Name does match",
9595
configName: "appConfig",
9696
outputFormat: "list",
97-
expectedOutput: " NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \n default appConfig false false 0s " + formattedNow + " \n",
97+
expectedOutput: "NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \ndefault appConfig false false 0s " + formattedNow + " \n",
9898
errString: "",
9999
errorExpected: false,
100100
k8sConfig: []v1alpha1.Configuration{
@@ -112,7 +112,7 @@ func TestConfigurations(t *testing.T) {
112112
name: "Name does not match",
113113
configName: "appConfig",
114114
outputFormat: "list",
115-
expectedOutput: " NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \n",
115+
expectedOutput: "NAMESPACE NAME TRACING-ENABLED METRICS-ENABLED AGE CREATED \n",
116116
errString: "",
117117
errorExpected: false,
118118
k8sConfig: []v1alpha1.Configuration{

tests/apps/scheduler/app.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
func main() {
33-
const port = 9084
33+
const port = 9095
3434

3535
ctx := signals.Context()
3636

@@ -42,10 +42,17 @@ func main() {
4242
close(regCh)
4343
w.Write([]byte(`{"entities": ["myactortype"]}`))
4444
})
45-
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {})
45+
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {})
4646

4747
go func() {
48-
<-regCh
48+
log.Printf("Waiting for registration call...")
49+
select {
50+
case <-regCh:
51+
log.Printf("Registration call received")
52+
case <-ctx.Done():
53+
log.Printf("Context done while waiting for registration call")
54+
return
55+
}
4956
register(ctx)
5057
}()
5158

@@ -55,10 +62,13 @@ func main() {
5562
func register(ctx context.Context) {
5663
log.Printf("Registering jobs, reminders and workflows")
5764

58-
cl, err := client.NewClient()
65+
addr := "127.0.0.1:3510"
66+
log.Printf("Creating client to %s", addr)
67+
cl, err := client.NewClientWithAddress(addr)
5968
if err != nil {
6069
log.Fatal(err)
6170
}
71+
log.Println("Client created")
6272

6373
ds := time.Now().Format(time.RFC3339)
6474

@@ -77,6 +87,8 @@ func register(ctx context.Context) {
7787
log.Fatal(err)
7888
}
7989

90+
log.Printf("Scheduled job test1")
91+
8092
if err = cl.ScheduleJobAlpha1(ctx, &client.Job{
8193
Name: "test2",
8294
Schedule: ptr.Of("@every 100m"),
@@ -88,6 +100,8 @@ func register(ctx context.Context) {
88100
log.Fatal(err)
89101
}
90102

103+
log.Printf("Scheduled job test2")
104+
91105
if err = cl.RegisterActorReminder(ctx, &client.RegisterActorReminderRequest{
92106
ActorType: "myactortype",
93107
ActorID: "actorid1",
@@ -98,6 +112,8 @@ func register(ctx context.Context) {
98112
log.Fatal(err)
99113
}
100114

115+
log.Printf("Scheduled actor reminder test1")
116+
101117
if err = cl.RegisterActorReminder(ctx, &client.RegisterActorReminderRequest{
102118
ActorType: "myactortype",
103119
ActorID: "actorid2",
@@ -108,6 +124,8 @@ func register(ctx context.Context) {
108124
log.Fatal(err)
109125
}
110126

127+
log.Printf("Scheduled actor reminder test2")
128+
111129
r := workflow.NewRegistry()
112130

113131
if err := r.AddWorkflow(W1); err != nil {
@@ -132,21 +150,35 @@ func register(ctx context.Context) {
132150
if _, err = wf.ScheduleWorkflow(ctx, "W1", workflow.WithInstanceID("abc1")); err != nil {
133151
log.Fatal(err)
134152
}
153+
154+
log.Printf("Scheduled workflow W1 with id abc1")
155+
135156
if _, err = wf.ScheduleWorkflow(ctx, "W1", workflow.WithInstanceID("abc2")); err != nil {
136157
log.Fatal(err)
137158
}
159+
160+
log.Printf("Scheduled workflow W1 with id abc2")
161+
138162
if _, err = wf.ScheduleWorkflow(ctx, "W2", workflow.WithInstanceID("xyz1")); err != nil {
139163
log.Fatal(err)
140164
}
165+
166+
log.Printf("Scheduled workflow W2 with id xyz1")
167+
141168
if _, err = wf.ScheduleWorkflow(ctx, "W2", workflow.WithInstanceID("xyz2")); err != nil {
142169
log.Fatal(err)
143170
}
171+
172+
log.Printf("Scheduled workflow W2 with id xyz2")
144173
}
145174

146175
// StartServer starts a HTTP or HTTP2 server
147176
func StartServer(ctx context.Context, port int, handler http.Handler) {
148177
// Create a listener
149178
addr := fmt.Sprintf(":%d", port)
179+
180+
log.Println("Starting server on ", addr)
181+
150182
ln, err := net.Listen("tcp", addr)
151183
if err != nil {
152184
log.Fatalf("Failed to create listener: %v", err)
@@ -167,6 +199,7 @@ func StartServer(ctx context.Context, port int, handler http.Handler) {
167199
server.Shutdown(ctx)
168200
}()
169201

202+
log.Printf("Server listening on %s", addr)
170203
err = server.Serve(ln)
171204

172205
if err != http.ErrServerClosed {

0 commit comments

Comments
 (0)