Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Jan 28, 2025
1 parent d4f73a8 commit a931733
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion neonvm-daemon/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func (s *cpuServer) getFile(path string) (string, error) {
if !filepath.IsLocal(path) {
return "", fmt.Errorf("\"%s\" is not a local path", path)
}
path = filepath.Clean(filepath.Join("var", "sync", path))
//nolint:gocritic // filepathJoin lint wrongly complains about path separators
path = filepath.Clean(filepath.Join("/var/sync", path))
return path, nil
}

Expand Down
14 changes: 14 additions & 0 deletions neonvm-runner/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,20 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d
// not tracking this file
continue
}
if event.Op == fsnotify.Chmod {
// not interesting.
continue
}

// kubernetes secrets are mounted as symbolic links.
// When the link changes, there's no event. We only see the deletion
// of the file the link used to point to.
// This doesn't mean the file was actually deleted though.
if event.Op == fsnotify.Remove {
if err := notify.Add(event.Name); err != nil {
logger.Error("failed to add file to inotify instance", zap.Error(err))
}
}

if err := sendFileToNeonvmDaemon(ctx, event.Name, guestpath); err != nil {
logger.Error("failed to upload file to vm guest", zap.Error(err))
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/vm-secret-sync/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 90
timeout: 70
commands:
- script: |
set -eux
pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')"
kubectl exec -n "$NAMESPACE" $pod -- grep -q "hello world" /vm/mounts/var/sync/example/foo
kubectl exec -n "$NAMESPACE" $pod -- scp guest-vm:/var/sync/example/foo testfile
grep -q "hello world" testfile
kubectl exec -n "$NAMESPACE" $pod -- grep -q "hello world" testfile
---
apiVersion: vm.neon.tech/v1
kind: VirtualMachine
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/vm-secret-sync/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 90
timeout: 70
commands:
- script: |
set -eux
pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')"
kubectl exec -n "$NAMESPACE" $pod -- grep -q "goodbye world" /vm/mounts/var/sync/example/foo
kubectl exec -n "$NAMESPACE" $pod -- scp guest-vm:/var/sync/example/foo testfile
grep -q "goodbye world" testfile
kubectl exec -n "$NAMESPACE" $pod -- grep -q "goodbye world" testfile
7 changes: 0 additions & 7 deletions tests/e2e/vm-secret-sync/01-update-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
unitTest: false
commands:
- script: |
set -eux
pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')"
new_size=$(( 1 * 1024 * 1024 )) # 1 Gi
mountpoint="/var/db/postgres/compute"
kubectl exec -n "$NAMESPACE" "$pod" -- ssh guest-vm /neonvm/bin/set-disk-quota "$new_size" "$mountpoint"
---
apiVersion: v1
kind: Secret
Expand Down

0 comments on commit a931733

Please sign in to comment.