forked from wunderio/csi-rclone
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b1c05
commit 2bb3647
Showing
9 changed files
with
194 additions
and
6 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 |
---|---|---|
|
@@ -36,7 +36,38 @@ jobs: | |
init-kind-cluster | ||
local-deploy | ||
get-kind-kubeconfig | ||
go test -v ./... | ||
go test -v test/sanity_test.go | ||
- name: Print rclone log | ||
if: ${{ failure() }} | ||
run: cat /tmp/rclone.log | ||
tests-with-decryption: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install fuse | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y fuse3 | ||
sudo bash -c 'echo "user_allow_other" >> /etc/fuse.conf' | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- uses: cachix/install-nix-action@v22 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- name: Flake check | ||
run: nix flake check | ||
- name: Helm check | ||
run: helm lint deploy/csi-rclone | ||
- name: Run tests with secret decryption | ||
uses: workflow/[email protected] | ||
with: | ||
flakes-from-devshell: true | ||
script: | | ||
init-kind-cluster | ||
local-deploy | ||
get-kind-kubeconfig | ||
go test -v test/sanity_with_decrypt_test.go | ||
- name: Print rclone log | ||
if: ${{ failure() }} | ||
run: cat /tmp/rclone.log |
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
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
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,91 @@ | ||
package test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/SwissDataScienceCenter/csi-rclone/pkg/kube" | ||
"github.com/SwissDataScienceCenter/csi-rclone/pkg/rclone" | ||
"github.com/kubernetes-csi/csi-test/v5/pkg/sanity" | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestMyDriverWithDecryption(t *testing.T) { | ||
// Setup the full driver and its environment | ||
endpoint := "unix:///tmp/plugin/csi.sock" | ||
kubeClient, err := kube.GetK8sClient() | ||
if err != nil { | ||
panic(err) | ||
} | ||
os.Setenv("DRIVER_NAME", "csi-rclone") | ||
driver := rclone.NewDriver("hostname", endpoint, kubeClient) | ||
go driver.Run() | ||
err = os.MkdirAll("/tmp/sanity/mount/", 0700) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
err = os.MkdirAll("/tmp/sanity/stage/", 0700) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
err = os.MkdirAll("/tmp/plugin/", 0700) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
mntDir, err := os.MkdirTemp("/tmp/sanity/mount/", "mount") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
os.RemoveAll(mntDir) | ||
//defer os.RemoveAll(mntDir) | ||
|
||
mntStageDir, err := os.MkdirTemp("/tmp/sanity/stage/", "stage") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
os.Getwd() | ||
os.RemoveAll(mntStageDir) | ||
//defer os.RemoveAll(mntStageDir) | ||
|
||
// create secret containing storage config for use in the test | ||
kubeClient.CoreV1().Secrets("csi-rclone").Create(context.Background(), &v1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "test-pvc", Namespace: "csi-rclone"}, | ||
StringData: map[string]string{ | ||
"remote": "my-s3", | ||
"remotePath": "giab/", | ||
"secretKey": "cw_0x689RpI-jtRR7oE8h_eQsKImvJapLeSbXpwF4e4=", | ||
"configData": `[my-s3] | ||
type=<sensitive> | ||
provider=AWS`}, | ||
Type: "Opaque", | ||
}, metav1.CreateOptions{}) | ||
|
||
// create secret containing saved storage secrets. `type` which is `s3` is encrypted like a secret | ||
// if decryption fails, then the storage cannot be mounted | ||
kubeClient.CoreV1().Secrets("csi-rclone").Create(context.Background(), &v1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "test-pvc-secrets", Namespace: "csi-rclone"}, | ||
StringData: map[string]string{"type": "gAAAAABK-fBwYcjuQgctfZknI2ko2uLqj6DRzRa7kFTKnWm_nkjwGWGTai5eyhNXlp6_6QjeTC7B8IWvhBsvG1Q6Zk2eDYDVQg=="}, | ||
Type: "Opaque", | ||
}, metav1.CreateOptions{}) | ||
|
||
cfg := sanity.NewTestConfig() | ||
cfg.Address = endpoint | ||
|
||
cfg.TargetPath = mntDir | ||
cfg.StagingPath = mntStageDir | ||
cfg.Address = endpoint | ||
// cfg.SecretsFile = "testdata/secrets.yaml" | ||
cfg.TestVolumeParameters = map[string]string{ | ||
"csi.storage.k8s.io/pvc/namespace": "csi-rclone", | ||
"csi.storage.k8s.io/pvc/name": "test-pvc", | ||
} | ||
sanity.Test(t, cfg) | ||
|
||
// sanity just completely kills the driver, leaking the rclone daemon, so we cleanup manually | ||
driver.RcloneOps.Cleanup() | ||
|
||
kubeClient.CoreV1().Secrets("csi-rclone").Delete(context.Background(), "test-pvc", metav1.DeleteOptions{}) | ||
} |