2018-07-14 08:48:22 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 The Kubernetes 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package s3
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/kubernetes-csi/csi-test/pkg/sanity"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDriver(t *testing.T) {
|
|
|
|
socket := "/tmp/csi.sock"
|
|
|
|
endpoint := "unix://" + socket
|
|
|
|
|
|
|
|
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
|
|
|
|
t.Fatalf("failed to remove unix domain socket file %s, error: %s", socket, err)
|
|
|
|
}
|
2018-07-16 18:24:54 +00:00
|
|
|
cfg := &Config{
|
2018-07-14 08:48:22 +00:00
|
|
|
AccessKeyID: "FJDSJ",
|
|
|
|
SecretAccessKey: "DSG643HGDS",
|
|
|
|
Endpoint: "http://127.0.0.1:9000",
|
2018-07-16 20:27:45 +00:00
|
|
|
EncryptionKey: "IskEwCuEg6drywi",
|
2018-07-14 08:48:22 +00:00
|
|
|
}
|
2018-07-16 18:24:54 +00:00
|
|
|
driver, err := NewS3("test-node", endpoint, cfg)
|
2018-07-14 08:48:22 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
go driver.Run()
|
|
|
|
|
|
|
|
mntDir, err := ioutil.TempDir("", "mnt")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(mntDir)
|
|
|
|
|
2018-07-16 18:24:54 +00:00
|
|
|
sanityCfg := &sanity.Config{
|
2018-07-14 08:48:22 +00:00
|
|
|
TargetPath: mntDir,
|
|
|
|
Address: endpoint,
|
|
|
|
}
|
|
|
|
|
2018-07-16 18:24:54 +00:00
|
|
|
sanity.Test(t, sanityCfg)
|
2018-07-14 08:48:22 +00:00
|
|
|
}
|