Restoring authRestart and dhcpRestart options
Change-Id: Ibeb26aa1cf4c6bfa984913edab1e51961c39522a
diff --git a/internal/bbsim/devices/service_test.go b/internal/bbsim/devices/service_test.go
index a2b720d..548a14a 100644
--- a/internal/bbsim/devices/service_test.go
+++ b/internal/bbsim/devices/service_test.go
@@ -19,6 +19,7 @@
import (
"context"
"github.com/opencord/bbsim/internal/bbsim/types"
+ "github.com/opencord/bbsim/internal/common"
"github.com/opencord/voltha-protos/v3/go/openolt"
"github.com/stretchr/testify/assert"
"net"
@@ -236,6 +237,13 @@
// Test that if the EAPOL state machine doesn't complete in 30 seconds we
// move it to EAPOL failed
func TestService_EAPOLFailed(t *testing.T) {
+
+ common.Config = &common.GlobalConfig{
+ BBSim: common.BBSimConfig{
+ AuthRetry: false,
+ },
+ }
+
// override the default wait time
eapolWaitTime = 500 * time.Millisecond
s, err := createTestService(true, false)
@@ -261,9 +269,42 @@
}
+func TestService_EAPOLRestart(t *testing.T) {
+
+ common.Config = &common.GlobalConfig{
+ BBSim: common.BBSimConfig{
+ AuthRetry: true,
+ },
+ }
+
+ eapolWaitTime = 500 * time.Millisecond
+ s, err := createTestService(true, false)
+
+ assert.Nil(t, err)
+
+ stream := &mockStream{
+ Calls: make(map[int]*openolt.Indication),
+ }
+ s.Initialize(stream)
+
+ // set to failed if timeout occurs
+ _ = s.EapolState.Event("start_auth")
+
+ // after a second EAPOL should have failed and restarted
+ time.Sleep(1 * time.Second)
+ assert.Equal(t, "eap_start_sent", s.EapolState.Current())
+}
+
// Test that if the DHCP state machine doesn't complete in 30 seconds we
// move it to DHCP failed
func TestService_DHCPFailed(t *testing.T) {
+
+ common.Config = &common.GlobalConfig{
+ BBSim: common.BBSimConfig{
+ DhcpRetry: false,
+ },
+ }
+
// override the default wait time
dhcpWaitTime = 100 * time.Millisecond
s, err := createTestService(false, true)
@@ -287,3 +328,27 @@
time.Sleep(1 * time.Second)
assert.Equal(t, "dhcp_ack_received", s.DHCPState.Current())
}
+
+func TestService_DHCPRestart(t *testing.T) {
+ common.Config = &common.GlobalConfig{
+ BBSim: common.BBSimConfig{
+ DhcpRetry: true,
+ },
+ }
+
+ // override the default wait time
+ dhcpWaitTime = 100 * time.Millisecond
+ s, err := createTestService(false, true)
+
+ assert.Nil(t, err)
+
+ stream := &mockStream{
+ Calls: make(map[int]*openolt.Indication),
+ }
+ s.Initialize(stream)
+
+ // set to failed if timeout occurs
+ _ = s.DHCPState.Event("start_dhcp")
+ time.Sleep(1 * time.Second)
+ assert.Equal(t, "dhcp_discovery_sent", s.DHCPState.Current())
+}