VOL-291 : PON simulator refactoring for cluster integration
- Added ponsim build target in Makefile
- Added new option to vcore to select comm type with ponsim
- Modified all proto files to include destination go package
Amendments:
- Clean up based on review comments
- Properly close GRPC connections in ponsim_olt adapter
- Added voltha namespace to some k8s templates
Change-Id: I2f349fa7b3550a8a8cc8fc676cc896f33fbb9372
diff --git a/ponsim/v2/common/interval_handler_test.go b/ponsim/v2/common/interval_handler_test.go
new file mode 100644
index 0000000..e1f060f
--- /dev/null
+++ b/ponsim/v2/common/interval_handler_test.go
@@ -0,0 +1,72 @@
+package common
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+var (
+ handler *IntervalHandler
+ iteration int = 0
+ interval int = 2
+)
+
+func RepeatMessage() {
+ fmt.Printf("Ran the function %d times\n", iteration)
+ iteration += 1
+}
+
+func TestNewIntervalHandler(t *testing.T) {
+ handler = NewIntervalHandler(interval, RepeatMessage)
+
+ if handler.state != STOPPED {
+ t.Error("The handler should be in STOPPED state", handler.state)
+ }
+ if handler.Interval != interval {
+ t.Error("The handler interval doesn't match the configured value", handler.Interval)
+ }
+ if handler.function == nil {
+ t.Error("The handler does not have function configured function", handler.function)
+ }
+}
+
+func TestIntervalHandler_Start(t *testing.T) {
+ handler.Start()
+
+ time.Sleep(5 * time.Second)
+
+ if handler.state != STARTED {
+ t.Error("The handler should be in STARTED state", handler.state)
+ }
+}
+
+func TestIntervalHandler_Pause(t *testing.T) {
+ handler.Pause()
+
+ if handler.state != PAUSED {
+ t.Error("The handler should be in PAUSED state", handler.state)
+ }
+
+ time.Sleep(5 * time.Second)
+}
+
+func TestIntervalHandler_Resume(t *testing.T) {
+ handler.Resume()
+
+ time.Sleep(5 * time.Second)
+
+ if handler.state != STARTED {
+ t.Error("The handler should be in STARTED state", handler.state)
+ }
+}
+
+func TestIntervalHandler_Stop(t *testing.T) {
+ handler.Stop()
+
+ if handler.state != STOPPED {
+ t.Error("The handler should be in STOPPED state", handler.state)
+ }
+
+ time.Sleep(5 * time.Second)
+}