(t *testing.T)
| 863 | } |
| 864 | |
| 865 | func TestCompactIntervalFromConfig(t *testing.T) { |
| 866 | testCases := []struct { |
| 867 | name string |
| 868 | compactIntervalDays *float32 |
| 869 | expectedCompactIntervalSecs uint32 |
| 870 | }{ |
| 871 | { |
| 872 | name: "compact interval days not set", |
| 873 | compactIntervalDays: nil, |
| 874 | expectedCompactIntervalSecs: uint32(db.DefaultCompactInterval.Seconds()), |
| 875 | }, |
| 876 | { |
| 877 | name: "explicit 1", |
| 878 | compactIntervalDays: base.Ptr(float32(1)), |
| 879 | expectedCompactIntervalSecs: uint32((24 * time.Hour).Seconds()), |
| 880 | }, |
| 881 | { |
| 882 | name: "1.5", |
| 883 | compactIntervalDays: base.Ptr(float32(1.5)), |
| 884 | expectedCompactIntervalSecs: uint32((1.5 * 24 * time.Hour).Seconds()), |
| 885 | }, |
| 886 | { |
| 887 | name: "2", |
| 888 | compactIntervalDays: base.Ptr(float32(2)), |
| 889 | expectedCompactIntervalSecs: uint32((2 * 24 * time.Hour).Seconds()), |
| 890 | }, |
| 891 | } |
| 892 | for _, test := range testCases { |
| 893 | t.Run(test.name, func(t *testing.T) { |
| 894 | |
| 895 | ctx := base.TestCtx(t) |
| 896 | startupConfig := &StartupConfig{} |
| 897 | sc := NewServerContext(ctx, startupConfig, false) |
| 898 | defer sc.Close(ctx) |
| 899 | config := &DbConfig{ |
| 900 | CompactIntervalDays: test.compactIntervalDays, |
| 901 | Unsupported: &db.UnsupportedOptions{}, |
| 902 | } |
| 903 | opts, err := dbcOptionsFromConfig(base.TestCtx(t), sc, config, "fakedb") |
| 904 | require.NoError(t, err) |
| 905 | require.Equal(t, int(test.expectedCompactIntervalSecs), int(opts.CompactInterval)) |
| 906 | }) |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | func TestHeapProfileValuesPopulated(t *testing.T) { |
| 911 | totalMemory := uint64(float64(getTotalMemory(base.TestCtx(t))) * 0.85) |
nothing calls this directly
no test coverage detected