mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Avoid non-writable /var/run
in integration tests
`/var/run` is not world-writable on my OSX 10.11.x setup, so tests that standup a secure apiserver fail with the default cert dir. Use a tempdir instead.
This commit is contained in:
parent
9fbefe3b97
commit
e847009d4d
@ -22,9 +22,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"mime"
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -395,7 +397,10 @@ const testNamespace = "etcdstoragepathtestnamespace"
|
|||||||
// It will also fail when a type gets moved to a different location. Be very careful in this situation because
|
// It will also fail when a type gets moved to a different location. Be very careful in this situation because
|
||||||
// it essentially means that you will be break old clusters unless you create some migration path for the old data.
|
// it essentially means that you will be break old clusters unless you create some migration path for the old data.
|
||||||
func TestEtcdStoragePath(t *testing.T) {
|
func TestEtcdStoragePath(t *testing.T) {
|
||||||
client, kvClient, mapper := startRealMasterOrDie(t)
|
certDir, _ := ioutil.TempDir("", "test-integration-etcd")
|
||||||
|
defer os.RemoveAll(certDir)
|
||||||
|
|
||||||
|
client, kvClient, mapper := startRealMasterOrDie(t, certDir)
|
||||||
defer func() {
|
defer func() {
|
||||||
dumpEtcdKVOnFailure(t, kvClient)
|
dumpEtcdKVOnFailure(t, kvClient)
|
||||||
}()
|
}()
|
||||||
@ -522,7 +527,7 @@ func TestEtcdStoragePath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func startRealMasterOrDie(t *testing.T) (*allClient, clientv3.KV, meta.RESTMapper) {
|
func startRealMasterOrDie(t *testing.T, certDir string) (*allClient, clientv3.KV, meta.RESTMapper) {
|
||||||
_, defaultServiceClusterIPRange, err := net.ParseCIDR("10.0.0.0/24")
|
_, defaultServiceClusterIPRange, err := net.ParseCIDR("10.0.0.0/24")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -535,6 +540,7 @@ func startRealMasterOrDie(t *testing.T) (*allClient, clientv3.KV, meta.RESTMappe
|
|||||||
for {
|
for {
|
||||||
kubeAPIServerOptions := options.NewServerRunOptions()
|
kubeAPIServerOptions := options.NewServerRunOptions()
|
||||||
kubeAPIServerOptions.SecureServing.BindAddress = net.ParseIP("127.0.0.1")
|
kubeAPIServerOptions.SecureServing.BindAddress = net.ParseIP("127.0.0.1")
|
||||||
|
kubeAPIServerOptions.SecureServing.ServerCert.CertDirectory = certDir
|
||||||
kubeAPIServerOptions.Etcd.StorageConfig.ServerList = []string{framework.GetEtcdURLFromEnv()}
|
kubeAPIServerOptions.Etcd.StorageConfig.ServerList = []string{framework.GetEtcdURLFromEnv()}
|
||||||
kubeAPIServerOptions.Etcd.DefaultStorageMediaType = runtime.ContentTypeJSON // TODO use protobuf?
|
kubeAPIServerOptions.Etcd.DefaultStorageMediaType = runtime.ContentTypeJSON // TODO use protobuf?
|
||||||
kubeAPIServerOptions.ServiceClusterIPRange = *defaultServiceClusterIPRange
|
kubeAPIServerOptions.ServiceClusterIPRange = *defaultServiceClusterIPRange
|
||||||
|
Loading…
Reference in New Issue
Block a user