github.com/argoproj/argo-events@v1.9.1/test/e2e/functional_test.go (about) 1 //go:build functional 2 3 package e2e 4 5 import ( 6 "crypto/tls" 7 "fmt" 8 "net/http" 9 "testing" 10 "time" 11 12 "github.com/argoproj/argo-events/test/e2e/fixtures" 13 "github.com/gavv/httpexpect/v2" 14 "github.com/stretchr/testify/suite" 15 ) 16 17 type FunctionalSuite struct { 18 fixtures.E2ESuite 19 } 20 21 const ( 22 LogEventSourceStarted = "Eventing server started." 23 LogSensorStarted = "Sensor started." 24 LogPublishEventSuccessful = "Succeeded to publish an event" 25 LogTriggerActionFailed = "Failed to execute a trigger" 26 ) 27 28 func LogTriggerActionSuccessful(triggerName string) string { 29 return fmt.Sprintf("Successfully processed trigger '%s'", triggerName) 30 } 31 32 func (s *FunctionalSuite) e(baseURL string) *httpexpect.Expect { 33 return httpexpect. 34 WithConfig(httpexpect.Config{ 35 BaseURL: baseURL, 36 Reporter: httpexpect.NewRequireReporter(s.T()), 37 Printers: []httpexpect.Printer{ 38 httpexpect.NewDebugPrinter(NewHttpLogger(), true), 39 }, 40 Client: &http.Client{ 41 Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}, 42 CheckRedirect: func(req *http.Request, via []*http.Request) error { 43 return http.ErrUseLastResponse 44 }, 45 }, 46 }). 47 Builder(func(req *httpexpect.Request) {}) 48 } 49 50 // func (s *FunctionalSuite) TestCreateCalendarEventSource() { 51 // t1 := s.Given().EventSource("@testdata/es-calendar.yaml"). 52 // When(). 53 // CreateEventSource(). 54 // WaitForEventSourceReady(). 55 // Then(). 56 // ExpectEventSourcePodLogContains(LogPublishEventSuccessful) 57 58 // defer t1.When().DeleteEventSource() 59 60 // t2 := s.Given().Sensor("@testdata/sensor-log.yaml"). 61 // When(). 62 // CreateSensor(). 63 // WaitForSensorReady(). 64 // Then(). 65 // ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger")) 66 67 // defer t2.When().DeleteSensor() 68 // } 69 70 // func (s *FunctionalSuite) TestCreateCalendarEventSourceWithHA() { 71 // for _, test := range []struct { 72 // es, s string 73 // }{ 74 // {"@testdata/es-calendar-ha.yaml", "@testdata/sensor-log-ha.yaml"}, 75 // {"@testdata/es-calendar-ha-k8s.yaml", "@testdata/sensor-log-ha-k8s.yaml"}, 76 // } { 77 // t1 := s.Given().EventSource(test.es). 78 // When(). 79 // CreateEventSource(). 80 // WaitForEventSourceReady(). 81 // Wait(3 * time.Second). 82 // Then(). 83 // ExpectEventSourcePodLogContains(LogPublishEventSuccessful) 84 85 // defer t1.When().DeleteEventSource() 86 87 // t2 := s.Given().Sensor(test.s). 88 // When(). 89 // CreateSensor(). 90 // WaitForSensorReady(). 91 // Wait(3 * time.Second). 92 // Then(). 93 // ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger")) 94 // defer t2.When().DeleteSensor() 95 // } 96 // } 97 98 // func (s *FunctionalSuite) TestMetricsWithCalendar() { 99 // w1 := s.Given().EventSource("@testdata/es-calendar-metrics.yaml"). 100 // When(). 101 // CreateEventSource(). 102 // WaitForEventSourceReady() 103 104 // defer w1.DeleteEventSource() 105 106 // w1.Then(). 107 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 108 109 // defer w1.Then().EventSourcePodPortForward(17777, 7777).TerminateAllPodPortForwards() 110 111 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful) 112 113 // // EventSource POD metrics 114 // s.e("http://localhost:17777").GET("/metrics"). 115 // Expect(). 116 // Status(200). 117 // Body(). 118 // Contains("argo_events_event_service_running_total"). 119 // Contains("argo_events_events_sent_total"). 120 // Contains("argo_events_event_processing_duration_milliseconds") 121 122 // w2 := s.Given().Sensor("@testdata/sensor-log-metrics.yaml"). 123 // When(). 124 // CreateSensor(). 125 // WaitForSensorReady() 126 // defer w2.DeleteSensor() 127 128 // w2.Then(). 129 // ExpectSensorPodLogContains(LogSensorStarted) 130 // defer w2.Then().SensorPodPortForward(17778, 7777).TerminateAllPodPortForwards() 131 132 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger")) 133 134 // // Sensor POD metrics 135 // s.e("http://localhost:17778").GET("/metrics"). 136 // Expect(). 137 // Status(200). 138 // Body(). 139 // Contains("argo_events_action_triggered_total"). 140 // Contains("argo_events_action_duration_milliseconds") 141 // } 142 143 func (s *FunctionalSuite) TestMetricsWithWebhook() { 144 w1 := s.Given().EventSource("@testdata/es-test-metrics-webhook.yaml"). 145 When(). 146 CreateEventSource(). 147 WaitForEventSourceReady() 148 149 defer w1.DeleteEventSource() 150 151 w1.Then().ExpectEventSourcePodLogContains(LogEventSourceStarted) 152 153 defer w1.Then(). 154 EventSourcePodPortForward(12300, 12000). 155 EventSourcePodPortForward(7717, 7777).TerminateAllPodPortForwards() 156 157 w2 := s.Given().Sensor("@testdata/sensor-test-metrics.yaml"). 158 When(). 159 CreateSensor(). 160 WaitForSensorReady() 161 162 defer w2.DeleteSensor() 163 w2.Then().ExpectSensorPodLogContains(LogSensorStarted) 164 165 defer w2.Then(). 166 SensorPodPortForward(7718, 7777).TerminateAllPodPortForwards() 167 168 time.Sleep(3 * time.Second) 169 170 s.e("http://localhost:12300").POST("/example").WithBytes([]byte("{}")). 171 Expect(). 172 Status(200) 173 174 w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful) 175 176 // Post something invalid 177 s.e("http://localhost:12300").POST("/example").WithBytes([]byte("Invalid JSON")). 178 Expect(). 179 Status(400) 180 181 // EventSource POD metrics 182 s.e("http://localhost:7717").GET("/metrics"). 183 Expect(). 184 Status(200). 185 Body(). 186 Contains("argo_events_event_service_running_total"). 187 Contains("argo_events_events_sent_total"). 188 Contains("argo_events_event_processing_duration_milliseconds"). 189 Contains("argo_events_events_processing_failed_total") 190 191 // Expect to see 1 success and 1 failure 192 w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger")). 193 ExpectSensorPodLogContains(LogTriggerActionFailed) 194 195 // Sensor POD metrics 196 s.e("http://localhost:7718").GET("/metrics"). 197 Expect(). 198 Status(200). 199 Body(). 200 Contains("argo_events_action_triggered_total"). 201 Contains("argo_events_action_duration_milliseconds"). 202 Contains("argo_events_action_failed_total") 203 } 204 205 // func (s *FunctionalSuite) TestResourceEventSource() { 206 // w1 := s.Given().EventSource("@testdata/es-resource.yaml"). 207 // When(). 208 // CreateEventSource(). 209 // WaitForEventSourceReady(). 210 // Exec("kubectl", []string{"-n", fixtures.Namespace, "run", "test-pod", "--image", "hello-world", "-l", fixtures.Label + "=" + fixtures.LabelValue}, fixtures.OutputRegexp(`pod/.* created`)) 211 212 // t1 := w1.Then(). 213 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 214 // defer t1.When().DeleteEventSource() 215 216 // t2 := s.Given().Sensor("@testdata/sensor-resource.yaml"). 217 // When(). 218 // CreateSensor(). 219 // WaitForSensorReady(). 220 // Then(). 221 // ExpectSensorPodLogContains(LogSensorStarted) 222 // defer t2.When().DeleteSensor() 223 224 // w1.Exec("kubectl", []string{"-n", fixtures.Namespace, "delete", "pod", "test-pod"}, fixtures.OutputRegexp(`pod "test-pod" deleted`)) 225 226 // t1.ExpectEventSourcePodLogContains(LogPublishEventSuccessful) 227 228 // t2.ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger")) 229 // } 230 231 // func (s *FunctionalSuite) TestMultiDependencyConditions() { 232 233 // w1 := s.Given().EventSource("@testdata/es-multi-dep.yaml"). 234 // When(). 235 // CreateEventSource(). 236 // WaitForEventSourceReady() 237 // defer w1.DeleteEventSource() 238 239 // w1.Then().ExpectEventSourcePodLogContains(LogEventSourceStarted) 240 241 // defer w1.Then(). 242 // EventSourcePodPortForward(12011, 12000). 243 // EventSourcePodPortForward(13011, 13000). 244 // EventSourcePodPortForward(14011, 14000). 245 // TerminateAllPodPortForwards() 246 247 // w2 := s.Given().Sensor("@testdata/sensor-multi-dep.yaml"). 248 // When(). 249 // CreateSensor(). 250 // WaitForSensorReady() 251 // defer w2.DeleteSensor() 252 253 // w2.Then().ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 254 255 // time.Sleep(3 * time.Second) 256 257 // // need to verify the conditional logic is working successfully 258 // // If we trigger test-dep-1 (port 12000) we should see log-trigger-2 but not log-trigger-1 259 // s.e("http://localhost:12011").POST("/example1").WithBytes([]byte("{}")). 260 // Expect(). 261 // Status(200) 262 263 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 264 265 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-2"), util.PodLogCheckOptionWithCount(1)). 266 // ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(0)) 267 268 // // Then if we trigger test-dep-2 we should see log-trigger-2 269 // s.e("http://localhost:13011").POST("/example2").WithBytes([]byte("{}")). 270 // Expect(). 271 // Status(200) 272 273 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(1)) 274 275 // // Then we trigger test-dep-2 again and shouldn't see anything 276 // s.e("http://localhost:13011").POST("/example2").WithBytes([]byte("{}")). 277 // Expect(). 278 // Status(200) 279 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(1)) 280 281 // // Finally trigger test-dep-3 and we should see log-trigger-1.. 282 // s.e("http://localhost:14011").POST("/example3").WithBytes([]byte("{}")). 283 // Expect(). 284 // Status(200) 285 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(2)) 286 // } 287 288 // // Start Pod with a multidependency condition 289 // // send it one dependency 290 // // verify that if it goes down and comes back up it triggers when sent the other part of the condition 291 // func (s *FunctionalSuite) TestDurableConsumer() { 292 // if fixtures.GetBusDriverSpec() == fixtures.E2EEventBusSTAN { 293 // s.T().SkipNow() // todo: TestDurableConsumer() is being skipped for now due to it not reliably passing with the STAN bus 294 // // (because when Sensor pod restarts it sometimes takes a little while for the STAN bus to resend the message to the durable consumer) 295 // } 296 297 // w1 := s.Given().EventSource("@testdata/es-durable-consumer.yaml"). 298 // When(). 299 // CreateEventSource(). 300 // WaitForEventSourceReady() 301 // defer w1.DeleteEventSource() 302 303 // w1.Then().ExpectEventSourcePodLogContains(LogEventSourceStarted) 304 305 // defer w1.Then(). 306 // EventSourcePodPortForward(12102, 12000). 307 // EventSourcePodPortForward(13102, 13000).TerminateAllPodPortForwards() 308 309 // w2 := s.Given().Sensor("@testdata/sensor-durable-consumer.yaml"). 310 // When(). 311 // CreateSensor(). 312 // WaitForSensorReady() 313 314 // w2.Then(). 315 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 316 317 // // test-dep-1 318 // s.e("http://localhost:12102").POST("/example1").WithBytes([]byte("{}")). 319 // Expect(). 320 // Status(200) 321 322 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 323 324 // // delete the Sensor 325 // w2.DeleteSensor().Then().ExpectNoSensorPodFound() 326 327 // w3 := s.Given().Sensor("@testdata/sensor-durable-consumer.yaml"). 328 // When(). 329 // CreateSensor(). 330 // WaitForSensorReady() 331 // defer w3.DeleteSensor() 332 333 // w3.Then(). 334 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 335 336 // // test-dep-2 337 // s.e("http://localhost:13102").POST("/example2").WithBytes([]byte("{}")). 338 // Expect(). 339 // Status(200) 340 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(2)) 341 // w3.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(1)) 342 // } 343 344 // func (s *FunctionalSuite) TestMultipleSensors() { 345 // // Start two sensors which each use "A && B", but staggered in time such that one receives the partial condition 346 // // Then send the other part of the condition and verify that only one triggers 347 348 // // Start EventSource 349 // w1 := s.Given().EventSource("@testdata/es-multi-sensor.yaml"). 350 // When(). 351 // CreateEventSource(). 352 // WaitForEventSourceReady() 353 // defer w1.DeleteEventSource() 354 355 // w1.Then(). 356 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 357 358 // defer w1.Then().EventSourcePodPortForward(12003, 12000). 359 // EventSourcePodPortForward(13003, 13000). 360 // EventSourcePodPortForward(14003, 14000).TerminateAllPodPortForwards() 361 362 // // Start one Sensor 363 // w2 := s.Given().Sensor("@testdata/sensor-multi-sensor.yaml"). 364 // When(). 365 // CreateSensor(). 366 // WaitForSensorReady() 367 // defer w2.DeleteSensor() 368 369 // w2.Then(). 370 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 371 372 // time.Sleep(3 * time.Second) 373 374 // // Trigger first dependency 375 // // test-dep-1 376 // s.e("http://localhost:12003").POST("/example1").WithBytes([]byte("{}")). 377 // Expect(). 378 // Status(200) 379 380 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 381 382 // // Start second Sensor 383 // w3 := s.Given().Sensor("@testdata/sensor-multi-sensor-2.yaml"). 384 // When(). 385 // CreateSensor(). 386 // WaitForSensorReady() 387 // defer w3.DeleteSensor() 388 389 // w3.Then(). 390 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 391 392 // // Trigger second dependency 393 // // test-dep-2 394 // s.e("http://localhost:13003").POST("/example2").WithBytes([]byte("{}")). 395 // Expect(). 396 // Status(200) 397 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(2)) 398 399 // // Verify trigger occurs for first Sensor and not second 400 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1")) 401 // w3.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(0)) 402 403 // } 404 405 // func (s *FunctionalSuite) TestAtLeastOnce() { 406 // // Send an event to a sensor with a failing trigger and make sure it doesn't ACK it. 407 // // Delete the sensor and launch sensor with same name and non-failing trigger so it ACKS it. 408 409 // if fixtures.GetBusDriverSpec() == fixtures.E2EEventBusSTAN { 410 // s.T().SkipNow() // Skipping because AtLeastOnce does not apply for NATS. 411 // } 412 413 // w1 := s.Given().EventSource("@testdata/es-webhook.yaml"). 414 // When(). 415 // CreateEventSource(). 416 // WaitForEventSourceReady() 417 418 // defer w1.DeleteEventSource() 419 420 // w1.Then(). 421 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 422 423 // defer w1.Then().EventSourcePodPortForward(12006, 12000). 424 // TerminateAllPodPortForwards() 425 426 // w2 := s.Given().Sensor("@testdata/sensor-atleastonce-fail.yaml"). 427 // When(). 428 // CreateSensor(). 429 // WaitForSensorReady() 430 // w2.Then(). 431 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 432 // time.Sleep(3 * time.Second) 433 // s.e("http://localhost:12006").POST("/example").WithBytes([]byte("{}")). 434 // Expect(). 435 // Status(200) 436 437 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 438 // w2.Then().ExpectSensorPodLogContains("Making a http request...") 439 // time.Sleep(5 * time.Second) // make sure we defintely attempt to trigger 440 441 // w2.DeleteSensor() 442 // time.Sleep(10 * time.Second) 443 444 // w3 := s.Given().Sensor("@testdata/sensor-atleastonce-succeed.yaml"). 445 // When(). 446 // CreateSensor(). 447 // WaitForSensorReady() 448 // defer w3.DeleteSensor() 449 450 // w3.Then(). 451 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 452 453 // w3.Then(). 454 // ExpectSensorPodLogContains(LogTriggerActionSuccessful("trigger-atleastonce")) 455 // } 456 457 // func (s *FunctionalSuite) TestAtMostOnce() { 458 // // Send an event to a sensor with a failing trigger but it will ACK it. 459 // // Delete the sensor and launch sensor with same name and non-failing trigger 460 // // to see that the event doesn't come through. 461 462 // w1 := s.Given().EventSource("@testdata/es-webhook.yaml"). 463 // When(). 464 // CreateEventSource(). 465 // WaitForEventSourceReady() 466 // defer w1.DeleteEventSource() 467 // w1.Then(). 468 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 469 470 // defer w1.Then().EventSourcePodPortForward(12007, 12000). 471 // TerminateAllPodPortForwards() 472 473 // w2 := s.Given().Sensor("@testdata/sensor-atmostonce-fail.yaml"). 474 // When(). 475 // CreateSensor(). 476 // WaitForSensorReady() 477 // w2.Then(). 478 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 479 // time.Sleep(3 * time.Second) 480 // s.e("http://localhost:12007").POST("/example").WithBytes([]byte("{}")). 481 // Expect(). 482 // Status(200) 483 484 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 485 // w2.Then().ExpectSensorPodLogContains("Making a http request...") 486 // time.Sleep(5 * time.Second) // make sure we defintely attempt to trigger 487 488 // w2.DeleteSensor() 489 // time.Sleep(10 * time.Second) 490 491 // w3 := s.Given().Sensor("@testdata/sensor-atmostonce-succeed.yaml"). 492 // When(). 493 // CreateSensor(). 494 // WaitForSensorReady() 495 // defer w3.DeleteSensor() 496 497 // w3.Then(). 498 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 499 500 // w3.Then(). 501 // ExpectSensorPodLogContains(LogTriggerActionSuccessful("trigger-atmostonce"), util.PodLogCheckOptionWithCount(0)) 502 // } 503 504 // func (s *FunctionalSuite) TestMultipleSensorAtLeastOnceTrigger() { 505 // // Start two sensors which each use "A && B", but staggered in time such that one receives the partial condition 506 // // Then send the other part of the condition and verify that only one triggers 507 // // With AtLeastOnce flag set. 508 509 // w1 := s.Given().EventSource("@testdata/es-multi-sensor.yaml"). 510 // When(). 511 // CreateEventSource(). 512 // WaitForEventSourceReady() 513 // defer w1.DeleteEventSource() 514 515 // w1.Then(). 516 // ExpectEventSourcePodLogContains(LogEventSourceStarted) 517 518 // defer w1.Then().EventSourcePodPortForward(12004, 12000). 519 // EventSourcePodPortForward(13004, 13000). 520 // EventSourcePodPortForward(14004, 14000).TerminateAllPodPortForwards() 521 522 // // Start one Sensor 523 // w2 := s.Given().Sensor("@testdata/sensor-multi-sensor-atleastonce.yaml"). 524 // When(). 525 // CreateSensor(). 526 // WaitForSensorReady() 527 // defer w2.DeleteSensor() 528 529 // w2.Then(). 530 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 531 532 // time.Sleep(3 * time.Second) 533 534 // // Trigger first dependency 535 // // test-dep-1 536 // s.e("http://localhost:12004").POST("/example1").WithBytes([]byte("{}")). 537 // Expect(). 538 // Status(200) 539 540 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 541 542 // // Start second Sensor 543 // w3 := s.Given().Sensor("@testdata/sensor-multi-sensor-2-atleastonce.yaml"). 544 // When(). 545 // CreateSensor(). 546 // WaitForSensorReady() 547 // defer w3.DeleteSensor() 548 549 // w3.Then(). 550 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 551 552 // // Trigger second dependency 553 // // test-dep-2 554 // s.e("http://localhost:13004").POST("/example2").WithBytes([]byte("{}")). 555 // Expect(). 556 // Status(200) 557 // w1.Then().ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(2)) 558 559 // // Verify trigger occurs for first Sensor and not second 560 // w2.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1-atleastonce")) 561 // w3.Then().ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1-atleastonce"), util.PodLogCheckOptionWithCount(0)) 562 // } 563 564 // func (s *FunctionalSuite) TestTriggerSpecChange() { 565 // // Start a sensor which uses "A && B"; send A; replace the Sensor with a new spec which uses A; send C and verify that there's no trigger 566 567 // // Start EventSource 568 // t1 := s.Given().EventSource("@testdata/es-trigger-spec-change.yaml"). 569 // When(). 570 // CreateEventSource(). 571 // WaitForEventSourceReady(). 572 // Then(). 573 // ExpectEventSourcePodLogContains(LogEventSourceStarted). 574 // EventSourcePodPortForward(12005, 12000). 575 // EventSourcePodPortForward(13005, 13000). 576 // EventSourcePodPortForward(14005, 14000) 577 578 // defer t1.When().DeleteEventSource() 579 // defer t1.TerminateAllPodPortForwards() 580 581 // // Start one Sensor 582 583 // t2 := s.Given().Sensor("@testdata/sensor-trigger-spec-change.yaml"). 584 // When(). 585 // CreateSensor(). 586 // WaitForSensorReady(). 587 // Then(). 588 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 589 590 // time.Sleep(3 * time.Second) 591 592 // // Trigger first dependency 593 // // test-dep-1 594 // s.e("http://localhost:12005").POST("/example").WithBytes([]byte("{}")). 595 // Expect(). 596 // Status(200) 597 598 // t1.ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(1)) 599 600 // t2.When().DeleteSensor().Then().ExpectNoSensorPodFound() 601 602 // // Change Sensor's spec 603 // t2 = s.Given().Sensor("@testdata/sensor-trigger-spec-change-2.yaml"). 604 // When(). 605 // CreateSensor(). 606 // WaitForSensorReady(). 607 // Then(). 608 // ExpectSensorPodLogContains(LogSensorStarted, util.PodLogCheckOptionWithCount(1)) 609 610 // defer t2.When().DeleteSensor() 611 612 // time.Sleep(3 * time.Second) 613 614 // // test-dep-3 615 // s.e("http://localhost:14005").POST("/example").WithBytes([]byte("{}")). 616 // Expect(). 617 // Status(200) 618 619 // t1.ExpectEventSourcePodLogContains(LogPublishEventSuccessful, util.PodLogCheckOptionWithCount(2)) 620 // // Verify no Trigger this time since test-dep-1 should have been cleared 621 // t2.ExpectSensorPodLogContains(LogTriggerActionSuccessful("log-trigger-1"), util.PodLogCheckOptionWithCount(0)) 622 // } 623 624 func TestFunctionalSuite(t *testing.T) { 625 suite.Run(t, new(FunctionalSuite)) 626 }