Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable fragment list consolidation tests. #344

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 60 additions & 50 deletions array_experimental_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tiledb

import (
"os"
"path"
"path/filepath"
"testing"

Expand Down Expand Up @@ -140,60 +141,69 @@ func TestGetConsolidationPlan(t *testing.T) {
}

func TestConsolidateFragments(t *testing.T) {
// The test is skipped pending a core release for 2.25.0 that includes this fix:
// https://github.com/TileDB-Inc/TileDB/pull/5135
t.Skip("Skipping fragment list consolidation SC-51140")

array := create1DTestArray(t)

numFrags := 5
for i := 0; i < numFrags; i++ {
write1DTestArray(t, array, []int32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
}

fragmentInfo, err := NewFragmentInfo(array.context, array.uri)
require.NoError(t, err)

err = fragmentInfo.Load()
require.NoError(t, err)
for _, test := range []struct {
name string
relativeURIs bool
}{
{"fragment list consolidation with relative URIs", true},
{"fragment list consolidation with absolute URIs", false},
} {
t.Run(test.name, func(t *testing.T) {
array := create1DTestArray(t)

numFrags := 5
for i := 0; i < numFrags; i++ {
write1DTestArray(t, array, []int32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
}

fragmentInfo, err := NewFragmentInfo(array.context, array.uri)
require.NoError(t, err)

fragInfoNum, err := fragmentInfo.GetFragmentNum()
require.NoError(t, err)
require.EqualValues(t, numFrags, fragInfoNum)
fragUris := make([]string, numFrags)
for i := 0; i < numFrags; i++ {
uri, err := fragmentInfo.GetFragmentURI(uint32(i))
require.NoError(t, err)
fragUris[i] = uri
}
err = fragmentInfo.Load()
require.NoError(t, err)

// Default consolidation mode is 'fragments'.
config, err := array.context.Config()
require.NoError(t, err)
fragInfoNum, err := fragmentInfo.GetFragmentNum()
require.NoError(t, err)
require.EqualValues(t, numFrags, fragInfoNum)
fragUris := make([]string, numFrags)
for i := 0; i < numFrags; i++ {
uri, err := fragmentInfo.GetFragmentURI(uint32(i))
require.NoError(t, err)
fragUris[i] = uri
if test.relativeURIs {
fragUris[i] = path.Base(fragUris[i])
}
}

// Default consolidation mode is 'fragments'.
config, err := array.context.Config()
require.NoError(t, err)

err = array.ConsolidateFragments(config, fragUris)
require.NoError(t, err)
err = array.ConsolidateFragments(config, fragUris)
require.NoError(t, err)

// Check that the new consolidated fragment was created.
err = fragmentInfo.Load()
require.NoError(t, err)
fragInfoNum, err = fragmentInfo.GetFragmentNum()
require.NoError(t, err)
fragToVacuumNum, err := fragmentInfo.GetToVacuumNum()
require.NoError(t, err)
require.EqualValues(t, numFrags, fragToVacuumNum)
require.Equal(t, uint32(1), fragInfoNum)
// Check that the new consolidated fragment was created.
err = fragmentInfo.Load()
require.NoError(t, err)
fragInfoNum, err = fragmentInfo.GetFragmentNum()
require.NoError(t, err)
fragToVacuumNum, err := fragmentInfo.GetToVacuumNum()
require.NoError(t, err)
require.EqualValues(t, numFrags, fragToVacuumNum)
require.Equal(t, uint32(1), fragInfoNum)

err = array.Vacuum(config)
require.NoError(t, err)
err = array.Vacuum(config)
require.NoError(t, err)

// Check for one fragment after vacuum.
err = fragmentInfo.Load()
require.NoError(t, err)
fragInfoNum, err = fragmentInfo.GetFragmentNum()
require.NoError(t, err)
fragToVacuumNum, err = fragmentInfo.GetToVacuumNum()
require.NoError(t, err)
require.Equal(t, uint32(1), fragInfoNum)
require.Equal(t, uint32(0), fragToVacuumNum)
// Check for one fragment after vacuum.
err = fragmentInfo.Load()
require.NoError(t, err)
fragInfoNum, err = fragmentInfo.GetFragmentNum()
require.NoError(t, err)
fragToVacuumNum, err = fragmentInfo.GetToVacuumNum()
require.NoError(t, err)
require.Equal(t, uint32(1), fragInfoNum)
require.Equal(t, uint32(0), fragToVacuumNum)
})
}
}
Loading