enable file and object store smoke test and fix naming conventions

This commit is contained in:
Divesh Angula
2017-05-09 22:40:53 -07:00
parent 3bc2c15e4b
commit e44cfe713b
8 changed files with 124 additions and 106 deletions
+21 -21
View File
@@ -34,7 +34,7 @@ var (
)
const (
temp_image_file_name = "temp_image.tar"
tempImageFileName = "temp_image.tar"
rookOperatorFileName = "rook-operator.yaml"
rookClusterFileName = "rook-cluster.yaml"
rookClientFileName = "rook-client.yml"
@@ -48,9 +48,9 @@ const (
rookOperatorPrefix = "quay.io/rook/rookd"
rookClientPrefix = "quay.io/rook/rook"
rookOperatorCreatedTpr = "cluster.rook.io"
k8s_master_container_name = "kube-master"
k8s_node1_container_name = "kube-node-1"
k8s_node2_container_name = "kube-node-2"
masterContinerName = "kube-master"
node1ContinerName = "kube-node-1"
node2ContinerName = "kube-node-2"
cephBaseImageName = "ceph/base"
defaultTagName = "master-latest"
)
@@ -170,30 +170,30 @@ func (r *rookTestInfraManager) copyImageToNode(containerId string, imageName str
cmdOut := utils.ExecuteCommand(objects.CommandArgs{Command: "docker", CmdArgs: []string{"pull", imageName}})
if cmdOut.Err != nil || cmdOut.ExitCode != 0 {
return fmt.Errorf("Failed to pull image")
panic(fmt.Errorf("Failed to pull image : %s", imageName))
}
fmt.Println("success...")
}
fmt.Println("archiving the docker image: " + temp_image_file_name)
cmdOut = utils.ExecuteCommand(objects.CommandArgs{Command: "docker", CmdArgs: []string{"save", "-o", temp_image_file_name, imageName}})
fmt.Println("archiving the docker image: " + tempImageFileName)
cmdOut = utils.ExecuteCommand(objects.CommandArgs{Command: "docker", CmdArgs: []string{"save", "-o", tempImageFileName, imageName}})
if cmdOut.Err != nil || cmdOut.ExitCode != 0 {
return fmt.Errorf("Failed to archive image")
panic(fmt.Errorf("Failed to archive image : %s", imageName))
}
fmt.Println("success...")
fmt.Println("copying archived image to node container")
_, _ = r.executeDockerCommand("", enums.Copy, temp_image_file_name, containerId+":/"+temp_image_file_name)
_, _ = r.executeDockerCommand("", enums.Copy, tempImageFileName, containerId+":/"+tempImageFileName)
if cmdOut.Err != nil || cmdOut.ExitCode != 0 {
return fmt.Errorf("Failed to copy image to container")
panic(fmt.Errorf("Failed to copy image to container : %s", imageName))
}
fmt.Println("success...")
fmt.Println("importing archived image into container registry")
_, _ = r.executeDockerCommand(containerId, enums.Exec, "/bin/bash", "-c", "docker load -i /"+temp_image_file_name)
_, _ = r.executeDockerCommand(containerId, enums.Exec, "/bin/bash", "-c", "docker load -i /"+tempImageFileName)
if cmdOut.Err != nil || cmdOut.ExitCode != 0 {
return fmt.Errorf("Failed load image into containers repository")
panic(fmt.Errorf("Failed load image into containers repository : %s", imageName))
}
fmt.Println("success...")
@@ -242,9 +242,9 @@ func (r *rookTestInfraManager) ValidateAndSetupTestPlatform() {
}
//if any of these methods fail, the executeDockerCommand will panic
k8sMasterContainerId := r.getContainerIdByName(k8s_master_container_name)
k8sNode1ContainerId := r.getContainerIdByName(k8s_node1_container_name)
k8sNode2ContainerId := r.getContainerIdByName(k8s_node2_container_name)
k8sMasterContainerId := r.getContainerIdByName(masterContinerName)
k8sNode1ContainerId := r.getContainerIdByName(node1ContinerName)
k8sNode2ContainerId := r.getContainerIdByName(node2ContinerName)
//install rbd shim
_, _ = r.executeDockerCommand("", enums.Copy, curdir+"/"+scriptsPath+"/rbd", k8sMasterContainerId+":/bin/rbd")
@@ -362,31 +362,31 @@ func (r *rookTestInfraManager) InstallRook(tag string) (err error, client contra
rookOperatorTag := rookOperatorPrefix + ":" + tag
rookClientTag := rookClientPrefix + ":" + tag
err = r.copyImageToNode(r.getContainerIdByName(k8s_master_container_name), rookOperatorTag)
err = r.copyImageToNode(r.getContainerIdByName(masterContinerName), rookOperatorTag)
if err != nil {
panic(err)
}
err = r.copyImageToNode(r.getContainerIdByName(k8s_node1_container_name), rookOperatorTag)
err = r.copyImageToNode(r.getContainerIdByName(node1ContinerName), rookOperatorTag)
if err != nil {
panic(err)
}
err = r.copyImageToNode(r.getContainerIdByName(k8s_node2_container_name), rookOperatorTag)
err = r.copyImageToNode(r.getContainerIdByName(node2ContinerName), rookOperatorTag)
if err != nil {
panic(err)
}
err = r.copyImageToNode(r.getContainerIdByName(k8s_master_container_name), rookClientTag)
err = r.copyImageToNode(r.getContainerIdByName(masterContinerName), rookClientTag)
if err != nil {
panic(err)
}
err = r.copyImageToNode(r.getContainerIdByName(k8s_node1_container_name), rookClientTag)
err = r.copyImageToNode(r.getContainerIdByName(node1ContinerName), rookClientTag)
if err != nil {
panic(err)
}
err = r.copyImageToNode(r.getContainerIdByName(k8s_node2_container_name), rookClientTag)
err = r.copyImageToNode(r.getContainerIdByName(node2ContinerName), rookClientTag)
if err != nil {
panic(err)
}
+44
View File
@@ -251,3 +251,47 @@ func (k8sh *K8sHelper) IsThirdPartyResourcePresent(tprname string) bool {
return false
}
func (k8sh *K8sHelper) GetPodDetails(podNamePattern string, namespace string) (string, error) {
cmdArgs := []string{"get", "pods", "-l", "app=" + podNamePattern, "-o", "wide", "--no-headers=true"}
if namespace != "" {
cmdArgs = append(cmdArgs, []string{"-n", namespace}...)
}
sout, serr, status := ExecuteCmd("kubectl", cmdArgs)
if status != 0 || strings.Contains(sout, "No resources found") {
return serr, fmt.Errorf("Cannot find pod in with name like %s in namespace : %s", podNamePattern, namespace)
}
return sout, nil
}
func (k8sh *K8sHelper) GetPodHostId(podNamePattern string, namespace string) (string, error) {
data, err := k8sh.GetPodDetails(podNamePattern, namespace)
if err != nil {
return data, err
}
// Handle case when no data is returned
lines := strings.Split(data, "\n")
//extract name of the pod
lineRawdata := strings.Split(lines[0], " ")
var r []string
for _, str := range lineRawdata {
if str != "" {
r = append(r, strings.TrimSpace(str))
}
}
//get host Ip of the pod
cmdArgs := []string{"get", "pods", r[0], "-o", "jsonpath='{.status.hostIP}'"}
if namespace != "" {
cmdArgs = append(cmdArgs, []string{"-n", namespace}...)
}
sout, serr, status := ExecuteCmd("kubectl", cmdArgs)
if status == 0 {
hostIp := strings.Replace(sout, "'", "", -1)
return strings.TrimSpace(hostIp), nil
} else {
return serr, fmt.Errorf("Error Getting Monitor IP")
}
}
-24
View File
@@ -1,7 +1,6 @@
package utils
import (
"fmt"
"strconv"
"strings"
)
@@ -221,26 +220,3 @@ func (rh *RookHelper) ParserObjectBucketListData(rawdata string) map[string]Obje
}
return data
}
func (rh *RookHelper) GetRgwServiceNodePort(rawdata string) (string, error) {
lines := strings.Split(rawdata, "\n")
if len(lines) <= 1 {
return "NOT FOUND", fmt.Errorf("Port not found")
}
lines = lines[1 : len(lines)-1]
if len(lines) == 1 {
bktsrawdata := strings.Split(lines[0], " ")
var r []string
for _, str := range bktsrawdata {
if str != "" {
r = append(r, strings.TrimSpace(str))
}
}
ports := strings.Split(r[3], ":")
port := strings.Replace(ports[1], "/TCP", "", -1)
return port, nil
} else {
return "NOT FOUND", fmt.Errorf("Port not found")
}
}
+18 -9
View File
@@ -2,29 +2,38 @@ package utils
import (
"bytes"
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"strings"
)
type S3Helper struct {
s3client *s3.S3
}
// create a s3 client for specfied endpoint and creds
func CreateNewS3Helper(endpoint string, keyId string, keySecret string) *S3Helper {
creds := credentials.NewStaticCredentials(keyId, keySecret, "")
_, err := creds.Get()
if err != nil {
fmt.Printf("bad credentials: %s", err)
}
cfg := aws.NewConfig().WithEndpoint(endpoint).WithRegion("us-west-1").WithCredentials(creds).WithDisableSSL(true)
svc := s3.New(session.New(), cfg)
// create aws s3 config, must use 'other-v2-signature' region for ceph object store
awsConfig := aws.NewConfig().
WithRegion("other-v2-signature").
WithCredentials(creds).
WithEndpoint(endpoint).
WithS3ForcePathStyle(true).
WithDisableSSL(true)
return &S3Helper{svc}
//create new session
ses := session.New()
//create new s3 client connection
c := s3.New(ses, awsConfig)
return &S3Helper{c}
}
func (h *S3Helper) CreateBucket(name string) (bool, error) {