aboutsummaryrefslogtreecommitdiff
path: root/test/foundationdb/validation_test.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-11-19 20:06:57 -0800
committerGitHub <noreply@github.com>2025-11-19 20:06:57 -0800
commitc6b6ea40e61b79722e1a539f814933898b9780a7 (patch)
tree3b09cd214ed6420881412ba9570122216d8df5bd /test/foundationdb/validation_test.go
parent8be9e258fc7d1110421aaee451945668cafa23e7 (diff)
downloadseaweedfs-c6b6ea40e61b79722e1a539f814933898b9780a7.tar.xz
seaweedfs-c6b6ea40e61b79722e1a539f814933898b9780a7.zip
filer store: add foundationdb (#7178)
* add foundationdb * Update foundationdb_store.go * fix * apply the patch * avoid panic on error * address comments * remove extra data * address comments * adds more debug messages * fix range listing * delete with prefix range; list with right start key * fix docker files * use the more idiomatic FoundationDB KeySelectors * address comments * proper errors * fix API versions * more efficient * recursive deletion * clean up * clean up * pagination, one transaction for deletion * error checking * Use fdb.Strinc() to compute the lexicographically next string and create a proper range * fix docker * Update README.md * delete in batches * delete in batches * fix build * add foundationdb build * Updated FoundationDB Version * Fixed glibc/musl Incompatibility (Alpine → Debian) * Update container_foundationdb_version.yml * build SeaweedFS * build tag * address comments * separate transaction * address comments * fix build * empty vs no data * fixes * add go test * Install FoundationDB client libraries * nil compare
Diffstat (limited to 'test/foundationdb/validation_test.go')
-rw-r--r--test/foundationdb/validation_test.go174
1 files changed, 174 insertions, 0 deletions
diff --git a/test/foundationdb/validation_test.go b/test/foundationdb/validation_test.go
new file mode 100644
index 000000000..ef387a774
--- /dev/null
+++ b/test/foundationdb/validation_test.go
@@ -0,0 +1,174 @@
+package foundationdb
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+// TestPackageStructure validates the FoundationDB package structure without requiring dependencies
+func TestPackageStructure(t *testing.T) {
+ t.Log("✅ Testing FoundationDB package structure...")
+
+ // Verify the main package files exist
+ packagePath := "../../weed/filer/foundationdb"
+ expectedFiles := map[string]bool{
+ "foundationdb_store.go": false,
+ "foundationdb_store_test.go": false,
+ "doc.go": false,
+ "README.md": false,
+ }
+
+ err := filepath.Walk(packagePath, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return nil // Skip errors
+ }
+ fileName := filepath.Base(path)
+ if _, exists := expectedFiles[fileName]; exists {
+ expectedFiles[fileName] = true
+ t.Logf("Found: %s", fileName)
+ }
+ return nil
+ })
+
+ if err != nil {
+ t.Logf("Warning: Could not access package path %s", packagePath)
+ }
+
+ for file, found := range expectedFiles {
+ if found {
+ t.Logf("✅ %s exists", file)
+ } else {
+ t.Logf("⚠️ %s not found (may be normal)", file)
+ }
+ }
+}
+
+// TestServerIntegration validates that the filer server includes FoundationDB import
+func TestServerIntegration(t *testing.T) {
+ t.Log("✅ Testing server integration...")
+
+ serverFile := "../../weed/server/filer_server.go"
+ content, err := os.ReadFile(serverFile)
+ if err != nil {
+ t.Skipf("Cannot read server file: %v", err)
+ return
+ }
+
+ contentStr := string(content)
+
+ // Check for FoundationDB import
+ if strings.Contains(contentStr, `"github.com/seaweedfs/seaweedfs/weed/filer/foundationdb"`) {
+ t.Log("✅ FoundationDB import found in filer_server.go")
+ } else {
+ t.Error("❌ FoundationDB import not found in filer_server.go")
+ }
+
+ // Check for other expected imports for comparison
+ expectedImports := []string{
+ "leveldb",
+ "redis",
+ "mysql",
+ }
+
+ foundImports := 0
+ for _, imp := range expectedImports {
+ if strings.Contains(contentStr, fmt.Sprintf(`"github.com/seaweedfs/seaweedfs/weed/filer/%s"`, imp)) {
+ foundImports++
+ }
+ }
+
+ t.Logf("✅ Found %d/%d expected filer store imports", foundImports, len(expectedImports))
+}
+
+// TestBuildConstraints validates that build constraints work correctly
+func TestBuildConstraints(t *testing.T) {
+ t.Log("✅ Testing build constraints...")
+
+ // Check that foundationdb package files have correct build tags
+ packagePath := "../../weed/filer/foundationdb"
+
+ err := filepath.Walk(packagePath, func(path string, info os.FileInfo, err error) error {
+ if err != nil || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
+ return nil
+ }
+
+ content, readErr := os.ReadFile(path)
+ if readErr != nil {
+ return nil
+ }
+
+ contentStr := string(content)
+
+ // Skip doc.go as it might not have build tags
+ if strings.HasSuffix(path, "doc.go") {
+ return nil
+ }
+
+ if strings.Contains(contentStr, "//go:build foundationdb") ||
+ strings.Contains(contentStr, "// +build foundationdb") {
+ t.Logf("✅ Build constraints found in %s", filepath.Base(path))
+ } else {
+ t.Logf("⚠️ No build constraints in %s", filepath.Base(path))
+ }
+
+ return nil
+ })
+
+ if err != nil {
+ t.Logf("Warning: Could not validate build constraints: %v", err)
+ }
+}
+
+// TestDocumentationExists validates that documentation files are present
+func TestDocumentationExists(t *testing.T) {
+ t.Log("✅ Testing documentation...")
+
+ docs := []struct {
+ path string
+ name string
+ }{
+ {"README.md", "Main README"},
+ {"Makefile", "Build automation"},
+ {"docker-compose.yml", "Docker setup"},
+ {"filer.toml", "Configuration template"},
+ {"../../weed/filer/foundationdb/README.md", "Package README"},
+ }
+
+ for _, doc := range docs {
+ if _, err := os.Stat(doc.path); err == nil {
+ t.Logf("✅ %s exists", doc.name)
+ } else {
+ t.Logf("⚠️ %s not found: %s", doc.name, doc.path)
+ }
+ }
+}
+
+// TestConfigurationValidation tests configuration file syntax
+func TestConfigurationValidation(t *testing.T) {
+ t.Log("✅ Testing configuration files...")
+
+ // Test filer.toml syntax
+ if content, err := os.ReadFile("filer.toml"); err == nil {
+ contentStr := string(content)
+
+ expectedConfigs := []string{
+ "[foundationdb]",
+ "enabled",
+ "cluster_file",
+ "api_version",
+ }
+
+ for _, config := range expectedConfigs {
+ if strings.Contains(contentStr, config) {
+ t.Logf("✅ Found config: %s", config)
+ } else {
+ t.Logf("⚠️ Config not found: %s", config)
+ }
+ }
+ } else {
+ t.Log("⚠️ filer.toml not accessible")
+ }
+}