This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override Cassandra configuration and launch Cassandra directly
* Bypass the entrypoint script of the chosen Docker image. * Instead, make direct changes to the Cassandra.yaml file. * And execute ``cassandra`` directly. * Add a pilot integration test
- Loading branch information
Showing
16 changed files
with
380 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
.generate_exes | ||
.get_deps | ||
bin/ | ||
**/.test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
apiVersion: navigator.jetstack.io/v1alpha1 | ||
kind: Pilot | ||
metadata: | ||
name: richards-pilot | ||
name: pilot1 | ||
namespace: ns1 | ||
ownerReferences: | ||
- apiVersion: navigator.jetstack.io/v1alpha1 | ||
kind: Pilot | ||
name: richards-pilot | ||
kind: CassandraCluster | ||
name: cluster1 | ||
uid: 23c88696-cf7b-11e7-9ec9-0a580a200927 | ||
controller: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package testfs | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type TestFs struct { | ||
t *testing.T | ||
d string | ||
} | ||
|
||
func New(t *testing.T) *TestFs { | ||
d := fmt.Sprintf(".test/%s", t.Name()) | ||
|
||
err := os.RemoveAll(d) | ||
if err != nil && !os.IsNotExist(err) { | ||
t.Fatalf("Error while removing old test directory: %s", err) | ||
} | ||
|
||
err = os.MkdirAll(d, os.ModePerm) | ||
require.NoError(t, err) | ||
|
||
return &TestFs{ | ||
t: t, | ||
d: d, | ||
} | ||
} | ||
|
||
func (tfs *TestFs) TempPath(name string) string { | ||
outPath := path.Join(tfs.d, name) | ||
tmpFile, err := ioutil.TempFile(tfs.d, name) | ||
require.NoError(tfs.t, err) | ||
err = tmpFile.Close() | ||
require.NoError(tfs.t, err) | ||
err = os.Rename(tmpFile.Name(), outPath) | ||
require.NoError(tfs.t, err) | ||
return outPath | ||
} | ||
|
||
func (tfs *TestFs) TempDir(name string) string { | ||
outPath := path.Join(tfs.d, name) | ||
tmpDir, err := ioutil.TempDir(tfs.d, name) | ||
require.NoError(tfs.t, err) | ||
err = os.Rename(tmpDir, outPath) | ||
require.NoError(tfs.t, err) | ||
return outPath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package config | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/golang/glog" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type config struct { | ||
*viper.Viper | ||
} | ||
|
||
type Interface interface { | ||
WriteConfigAs(filename string) error | ||
AllSettings() map[string]interface{} | ||
} | ||
|
||
var _ Interface = &config{} | ||
|
||
func NewFromYaml(path string) (Interface, error) { | ||
path, err := filepath.Abs(path) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to read absolute path") | ||
} | ||
glog.V(4).Infof("Reading file: %q", path) | ||
c := &config{viper.New()} | ||
c.SetConfigType("yaml") | ||
f, err := os.Open(path) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to open file") | ||
} | ||
err = c.ReadConfig(f) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "unable to read file") | ||
} | ||
return c, nil | ||
} | ||
|
||
func (c *config) WriteConfigAs(filename string) error { | ||
path, err := filepath.Abs(filename) | ||
if err != nil { | ||
return errors.Wrap(err, "unable to read absolute path") | ||
} | ||
glog.V(4).Infof("Writing file: %q", path) | ||
return c.Viper.WriteConfigAs(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package config_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/jetstack/navigator/internal/test/util/testfs" | ||
"github.com/jetstack/navigator/pkg/config" | ||
) | ||
|
||
func TestRoundTrip(t *testing.T) { | ||
tfs := testfs.New(t) | ||
|
||
inPath := "testdata/config1.yaml" | ||
outPath := tfs.TempPath("outPath1.yaml") | ||
|
||
c1, err := config.NewFromYaml(inPath) | ||
require.NoError(t, err) | ||
|
||
err = c1.WriteConfigAs(outPath) | ||
require.NoError(t, err) | ||
|
||
c2, err := config.NewFromYaml(outPath) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, c1.AllSettings(), c2.AllSettings()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
foo: | ||
- bar | ||
- baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.