mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
replace startuptest
This commit is contained in:
parent
74e7b66aa0
commit
5f33b3f933
@ -101,7 +101,7 @@ script:
|
||||
|
||||
- docker ps
|
||||
- ./tests/notarytest.sh
|
||||
- go run tests/startuptest.go https://localhost/
|
||||
- ./tests/startuptest.sh
|
||||
- go run tests/userlogintest.go -name ${HARBOR_ADMIN} -passwd ${HARBOR_ADMIN_PASSWD}
|
||||
|
||||
# - sudo ./tests/testprepare.sh
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Fetch prints the content found at a URL.
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
time.Sleep(60 * time.Second)
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
var client = &http.Client{
|
||||
Timeout: time.Second * 30,
|
||||
Transport: tr,
|
||||
}
|
||||
|
||||
for _, url := range os.Args[1:] {
|
||||
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "fetch: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "fetch: reading %s: %v\n", url, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// fmt.Printf("%s", b)
|
||||
|
||||
if strings.Contains(string(b), "Harbor") {
|
||||
fmt.Printf("sucess!\n")
|
||||
} else {
|
||||
fmt.Println("the response does not contain \"Harbor\"!")
|
||||
|
||||
fmt.Println(string(b))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
tests/startuptest.sh
Executable file
28
tests/startuptest.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
set +e
|
||||
|
||||
TIMEOUT=12
|
||||
while [ $TIMEOUT -gt 0 ]; do
|
||||
STATUS=$(curl --insecure -s -o /dev/null -w '%{http_code}' https://localhost/)
|
||||
if [ $STATUS -eq 200 ]; then
|
||||
break
|
||||
fi
|
||||
TIMEOUT=$(($TIMEOUT - 1))
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ $TIMEOUT -eq 0 ]; then
|
||||
echo "Harbor cannot reach within one minute."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl --insecure -s -L -H "Accept: application/json" https://localhost/ | grep "Harbor" > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Harbor is running success."
|
||||
else
|
||||
echo "Harbor is running fail."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user