Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions go/test/endtoend/cluster/vtctl_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ func (vtctl *VtctlProcess) ExecuteCommandWithOutput(args ...string) (result stri
return string(resultByte), err
}

// ExecuteCommand executes any vtctlclient command
func (vtctl *VtctlProcess) ExecuteCommand(args ...string) (err error) {
args = append([]string{
"-enable_queries",
"-topo_implementation", vtctl.TopoImplementation,
"-topo_global_server_address", vtctl.TopoGlobalAddress,
"-topo_global_root", vtctl.TopoGlobalRoot}, args...)
tmpProcess := exec.Command(
vtctl.Binary,
args...,
)
log.Info(fmt.Sprintf("Executing vtctlclient with arguments %v", strings.Join(tmpProcess.Args, " ")))
return tmpProcess.Run()
}

// VtctlProcessInstance returns a VtctlProcess handle for vtctl process
// configured with the given Config.
// The process must be manually started by calling setup()
Expand Down
41 changes: 41 additions & 0 deletions go/test/endtoend/encryption/encrypted_utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2019 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/* This test makes sure encrypted transport over gRPC works.*/

package encryption

import (
"os"
"os/exec"
)

// CreateDirectory will create directory with dirName
func CreateDirectory(dirName string, mode os.FileMode) error {
if _, err := os.Stat(dirName); os.IsNotExist(err) {
return os.Mkdir(dirName, mode)
}
return nil
}

// ExecuteVttlstestCommand executes vttlstest binary with passed args
func ExecuteVttlstestCommand(args ...string) error {
tmpProcess := exec.Command(
"vttlstest",
args...,
)
return tmpProcess.Run()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package encryption
package encryptedreplication

import (
"flag"
Expand All @@ -25,6 +25,7 @@ import (

"github.com/stretchr/testify/assert"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/encryption"
"vitess.io/vitess/go/vt/log"
)

Expand Down Expand Up @@ -101,15 +102,15 @@ func initializeCluster(t *testing.T) (int, error) {
// create certs directory
log.Info("Creating certificates")
certDirectory = path.Join(clusterInstance.TmpDirectory, "certs")
_ = createDirectory(certDirectory, 0700)
_ = encryption.CreateDirectory(certDirectory, 0700)

err := executeVttlstestCommand("-root", certDirectory, "CreateCA")
err := encryption.ExecuteVttlstestCommand("-root", certDirectory, "CreateCA")
assert.Nil(t, err)

err = executeVttlstestCommand("-root", certDirectory, "CreateSignedCert", "-common_name", "Mysql Server", "-serial", "01", "server")
err = encryption.ExecuteVttlstestCommand("-root", certDirectory, "CreateSignedCert", "-common_name", "Mysql Server", "-serial", "01", "server")
assert.Nil(t, err)

err = executeVttlstestCommand("-root", certDirectory, "CreateSignedCert", "-common_name", "Mysql Client", "-serial", "02", "client")
err = encryption.ExecuteVttlstestCommand("-root", certDirectory, "CreateSignedCert", "-common_name", "Mysql Client", "-serial", "02", "client")
assert.Nil(t, err)

extraMyCnf := path.Join(certDirectory, "secure.cnf")
Expand Down Expand Up @@ -185,18 +186,3 @@ func initializeCluster(t *testing.T) (int, error) {
func teardownCluster() {
clusterInstance.Teardown()
}

func createDirectory(dirName string, mode os.FileMode) error {
if _, err := os.Stat(dirName); os.IsNotExist(err) {
return os.Mkdir(dirName, mode)
}
return nil
}

func executeVttlstestCommand(args ...string) error {
tmpProcess := exec.Command(
"vttlstest",
args...,
)
return tmpProcess.Run()
}
Loading