diff --git a/service/features/service.feature b/service/features/service.feature index d5037f8c..1076d249 100644 --- a/service/features/service.feature +++ b/service/features/service.feature @@ -277,6 +277,7 @@ Feature: Isilon CSI interface | "blah" | "unknown" | "none" | "none" | "probe of all isilon clusters failed" | | "blah" | "controller" | "noIsiService" | "none" | "none" | | "blah" | "node" | "noIsiService" | "none" | "none" | + | "blah" | "" | "none" | "none" | "none" | Scenario Outline: Calling logStatistics different times Given a Isilon service @@ -287,8 +288,15 @@ Feature: Isilon CSI interface | times | errormsg | | 100 | "none" | + Scenario: Calling functions with noProbeOnStart set to true + Given a Isilon service + When I set noProbeOnStart to "true" + When I call BeforeServe + Then the error contains "none" + Scenario: Calling BeforeServe Given a Isilon service + When I set noProbeOnStart to "false" When I call BeforeServe Then the error contains "probe of all isilon clusters failed" @@ -345,33 +353,53 @@ Feature: Isilon CSI interface And I call NodeGetInfo Then a valid NodeGetInfoResponse is returned - Scenario: ControllerGetVolume good scenario - Given a Isilon service - When I call Probe - And I call ControllerGetVolume with name "volume2=_=_=43=_=_=System=_=_=cluster1" - Then a valid ControllerGetVolumeResponse is returned - - Scenario: ControllerGetVolume volume does not exist scenario - Given a Isilon service - When I call Probe - And I induce error "VolumeNotExistError" - And I call ControllerGetVolume with name "" - Then the error contains "no VolumeID found in request" - - Scenario: NodeGetVolumeStats volume does not exist scenario - Given a Isilon service - When I call Probe - And I induce error "VolumeNotExistError" - And I call NodeGetVolumeStats with name "" and path "" - Then the error contains "no VolumeID found in request" - - Scenario: NodeGetVolumeStats volume does not exist scenario - Given a Isilon service - When I call Probe - And I call NodeGetVolumeStats with name "volume2=_=_=43=_=_=System=_=_=cluster1" and path "" - Then the error contains "no Volume Path found in request" - - Scenario: Identity GetReplicationCapabilities call - Given a Isilon service - When I call GetReplicationCapabilities - Then a valid GetReplicationCapabilitiesResponse is returned + Scenario: ControllerGetVolume good scenario + Given a Isilon service + When I call Probe + And I call ControllerGetVolume with name "volume2=_=_=43=_=_=System=_=_=cluster1" + Then a valid ControllerGetVolumeResponse is returned + + Scenario: ControllerGetVolume volume does not exist scenario + Given a Isilon service + When I call Probe + And I induce error "VolumeNotExistError" + And I call ControllerGetVolume with name "" + Then the error contains "no VolumeID found in request" + + Scenario: NodeGetVolumeStats volume does not exist scenario + Given a Isilon service + When I call Probe + And I induce error "VolumeNotExistError" + And I call NodeGetVolumeStats with name "" and path "" + Then the error contains "no VolumeID found in request" + + Scenario: NodeGetVolumeStats volume does not exist scenario + Given a Isilon service + When I call Probe + And I call NodeGetVolumeStats with name "volume2=_=_=43=_=_=System=_=_=cluster1" and path "" + Then the error contains "no Volume Path found in request" + + Scenario: Identity GetReplicationCapabilities call + Given a Isilon service + When I call GetReplicationCapabilities + Then a valid GetReplicationCapabilitiesResponse is returned + + Scenario: Call Isilon Service with custom topology + Given a Isilon service with custom topology "blah" "controller" + When I call Probe + Then the error contains "probe of all isilon clusters failed" + + Scenario: Call ProbeController + Given a Isilon service + When I call Probe + And I call ProbeController + Then the error contains "none" + + Scenario Outline: Dynamic log config change + Given a Isilon service + When I call DynamicLogChange + Then a valid DynamicLogChange occurs + Examples: + | file | level | + | "logLevelInfo.yaml" | "info" | + | "logConfigError.yaml" | "debug" | diff --git a/service/mock/loglevel/logBackup.yaml b/service/mock/loglevel/logBackup.yaml new file mode 100644 index 00000000..e69de29b diff --git a/service/mock/loglevel/logConfig.yaml b/service/mock/loglevel/logConfig.yaml new file mode 100644 index 00000000..e8687b76 --- /dev/null +++ b/service/mock/loglevel/logConfig.yaml @@ -0,0 +1 @@ +CSI_LOG_LEVEL: "Debug" diff --git a/service/mock/loglevel/logConfigError.yaml b/service/mock/loglevel/logConfigError.yaml new file mode 100644 index 00000000..bcdefe41 --- /dev/null +++ b/service/mock/loglevel/logConfigError.yaml @@ -0,0 +1 @@ +CSI_LOG_LEVEL: "xyz" diff --git a/service/mock/loglevel/logLevelInfo.yaml b/service/mock/loglevel/logLevelInfo.yaml new file mode 100644 index 00000000..ebd3e110 --- /dev/null +++ b/service/mock/loglevel/logLevelInfo.yaml @@ -0,0 +1 @@ +CSI_LOG_LEVEL: "INFO" diff --git a/service/step_defs_test.go b/service/step_defs_test.go index 5509ff03..7e4af3d6 100644 --- a/service/step_defs_test.go +++ b/service/step_defs_test.go @@ -18,6 +18,7 @@ package service import ( "errors" "fmt" + "github.com/dell/csi-isilon/common/utils" "log" "net" "net/http/httptest" @@ -25,16 +26,19 @@ import ( "runtime" "strings" "sync" + "time" "github.com/dell/csi-isilon/common/constants" "github.com/dell/csi-isilon/common/k8sutils" csiext "github.com/dell/dell-csi-extensions/replication" + "google.golang.org/grpc" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os/exec" csi "github.com/container-storage-interface/spec/lib/go/csi" "github.com/cucumber/godog" + commonext "github.com/dell/dell-csi-extensions/common" podmon "github.com/dell/dell-csi-extensions/podmon" "github.com/dell/gocsi" "github.com/dell/gofsutil" @@ -103,6 +107,8 @@ type feature struct { getReplicationCapabilityRequest *csiext.GetReplicationCapabilityRequest getReplicationCapabilityResponse *csiext.GetReplicationCapabilityResponse validateVolumeHostConnectivityResp *podmon.ValidateVolumeHostConnectivityResponse + ProbeControllerRequest *commonext.ProbeControllerRequest + ProbeControllerResponse *commonext.ProbeControllerResponse volumeIDList []string snapshotIDList []string groupIDList []string @@ -247,6 +253,8 @@ func (f *feature) getService() *service { svc.opts = opts svc.mode = "controller" + server := grpc.NewServer() + svc.RegisterAdditionalServers(server) f.service = svc f.service.nodeID, _ = os.Hostname() f.service.nodeIP = "127.0.0.1" @@ -384,6 +392,10 @@ func FeatureContext(s *godog.Suite) { s.Step(`^a valid GetReplicationCapabilitiesResponse is returned$`, f.aValidGetReplicationCapabilitiesResponseIsReturned) s.Step(`^I call ValidateConnectivity$`, f.iCallValidateVolumeHostConnectivity) s.Step(`^the ValidateConnectivity response message contains "([^"]*)"$`, f.theValidateConnectivityResponseMessageContains) + s.Step(`^I call ProbeController$`, f.iCallProbeController) + s.Step(`^I call DynamicLogChange "([^"]*)"$`, f.iCallDynamicLogChange) + s.Step(`^a valid DynamicLogChange occurs "([^"]*)" "([^"]*)"$`, f.aValidDynamicLogChangeOccurs) + s.Step(`^I set noProbeOnStart to "([^"]*)"$`, f.iSetNoProbeOnStart) } // GetPluginInfo @@ -3057,3 +3069,43 @@ func (f *feature) theValidateConnectivityResponseMessageContains(expected string } return fmt.Errorf("Expected %s message in ValidateVolumeHostConnectivityResp but it wasn't there", expected) } + +func (f *feature) iCallProbeController() error { + header := metadata.New(map[string]string{"csi.requestid": "1"}) + ctx := metadata.NewIncomingContext(context.Background(), header) + req := &commonext.ProbeControllerRequest{} + connect, err := f.service.ProbeController(ctx, req) + if err != nil { + f.err = errors.New(err.Error()) + return nil + } + fmt.Printf("response is %v", connect) + return nil +} + +func (f *feature) iCallDynamicLogChange(file string) error { + log.Printf("level before change: %s", utils.GetCurrentLogLevel()) + DriverConfigParamsFile = "mock/loglevel/" + file + log.Printf("wait for config change %s", DriverConfigParamsFile) + f.iCallBeforeServe() + time.Sleep(10 * time.Second) + return nil +} + +func (f *feature) aValidDynamicLogChangeOccurs(file, expectedLevel string) error { + log.Printf("level after change: %s", utils.GetCurrentLogLevel()) + if utils.GetCurrentLogLevel().String() != expectedLevel { + err := fmt.Errorf("level was expected to be %s, but was %s instead", expectedLevel, utils.GetCurrentLogLevel().String()) + return err + } + log.Printf("Reverting log changes made") + DriverConfigParamsFile = "mock/loglevel/logConfig.yaml" + f.iCallBeforeServe() + time.Sleep(10 * time.Second) + return nil +} + +func (f *feature) iSetNoProbeOnStart(value string) error { + os.Setenv(constants.EnvNoProbeOnStart, value) + return nil +}