diff --git a/tests/ociswrapper/cmd/cmd.go b/tests/ociswrapper/cmd/cmd.go index ccd8047f4..66fc1d6c7 100644 --- a/tests/ociswrapper/cmd/cmd.go +++ b/tests/ociswrapper/cmd/cmd.go @@ -32,6 +32,8 @@ func serveCmd() *cobra.Command { ocisConfig.Set("bin", cmd.Flag("bin").Value.String()) ocisConfig.Set("url", cmd.Flag("url").Value.String()) ocisConfig.Set("retry", cmd.Flag("retry").Value.String()) + ocisConfig.Set("adminUsername", cmd.Flag("admin-username").Value.String()) + ocisConfig.Set("adminPassword", cmd.Flag("admin-password").Value.String()) }, } @@ -41,6 +43,8 @@ func serveCmd() *cobra.Command { serveCmd.Flags().StringP("url", "", ocisConfig.Get("url"), "oCIS server url") serveCmd.Flags().StringP("retry", "", ocisConfig.Get("retry"), "Number of retries to start oCIS server") serveCmd.Flags().StringP("port", "p", wrapperConfig.Get("port"), "Wrapper API server port") + serveCmd.Flags().StringP("admin-username", "", ocisConfig.Get("adminUsername"), "admin username for oCIS server") + serveCmd.Flags().StringP("admin-password", "", ocisConfig.Get("adminPassword"), "admin password for oCIS server") return serveCmd } diff --git a/tests/ociswrapper/ocis/config/config.go b/tests/ociswrapper/ocis/config/config.go index b495db73a..6fb43c4be 100644 --- a/tests/ociswrapper/ocis/config/config.go +++ b/tests/ociswrapper/ocis/config/config.go @@ -1,9 +1,11 @@ package config var config = map[string]string{ - "bin": "/usr/bin/ocis", - "url": "https://localhost:9200", - "retry": "5", + "bin": "/usr/bin/ocis", + "url": "https://localhost:9200", + "retry": "5", + "adminUsername": "admin", + "adminPassword": "admin", } func Set(key string, value string) { diff --git a/tests/ociswrapper/ocis/ocis.go b/tests/ociswrapper/ocis/ocis.go index 5bad143c7..785027d4c 100644 --- a/tests/ociswrapper/ocis/ocis.go +++ b/tests/ociswrapper/ocis/ocis.go @@ -83,14 +83,17 @@ func WaitForConnection() bool { transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } - // 5 seconds timeout - timeoutValue := 5 * time.Second + // 30 seconds timeout + timeoutValue := 30 * time.Second client := http.Client{ Timeout: timeoutValue, Transport: transport, } + req, _ := http.NewRequest("GET", config.Get("url")+"/graph/v1.0/users/"+config.Get("adminUsername"), nil) + req.SetBasicAuth(config.Get("adminUsername"), config.Get("adminPassword")) + timeout := time.After(timeoutValue) for { @@ -99,13 +102,17 @@ func WaitForConnection() bool { log.Println(fmt.Sprintf("%v seconds timeout waiting for oCIS server", int64(timeoutValue.Seconds()))) return false default: - _, err := client.Get(config.Get("url")) - if err == nil { - log.Println("oCIS server is ready to accept requests") - return true + req.Header.Set("X-Request-ID", "ociswrapper-"+strconv.Itoa(int(time.Now().UnixMilli()))) + + res, err := client.Do(req) + if err != nil || res.StatusCode != 200 { + // 500 milliseconds poll interval + time.Sleep(500 * time.Millisecond) + continue } - // 500 milliseconds poll interval - time.Sleep(500 * time.Millisecond) + + log.Println("oCIS server is ready to accept requests") + return true } } }