Skip to content

Commit

Permalink
Merge pull request ravendb#19024 from ppekrol/v6.2
Browse files Browse the repository at this point in the history
6.1 to 6.2 merge
  • Loading branch information
ppekrol authored Aug 7, 2024
2 parents 8f9c61c + 15714fe commit 7adfcf9
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ public interface IAbstractIndexCreationTask

DocumentConventions Conventions { get; set; }

SearchEngineType? SearchEngineType { get; }

IndexDefinition CreateIndexDefinition();

void Execute(IDocumentStore store, DocumentConventions conventions = null, string database = null);
Expand Down
4 changes: 4 additions & 0 deletions src/Raven.Client/Documents/Indexes/IndexCreation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ internal static IndexDefinition[] CreateIndexesToAdd(IEnumerable<IAbstractIndexC
definition.Name = x.IndexName;
definition.Priority = x.Priority ?? IndexPriority.Normal;
definition.State = x.State ?? IndexState.Normal;

if (x.SearchEngineType.HasValue)
definition.Configuration[Constants.Configuration.Indexes.IndexingStaticSearchEngineType] = x.SearchEngineType.Value.ToString();

return definition;
}
finally
Expand Down
5 changes: 3 additions & 2 deletions src/Raven.Server/Json/BlittableJsonTextWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Raven.Server.Documents.Subscriptions.Stats;
using Raven.Server.Utils;
using Sparrow;
using Sparrow.Extensions;
using Sparrow.Json;
using Sparrow.Json.Parsing;
using Voron.Data.BTrees;
Expand Down Expand Up @@ -878,11 +879,11 @@ await writer.WriteIncludesAsync(includeObjects, token)
throw new NotSupportedException($"Cannot write query includes of '{includes.GetType()}' type in '{result.GetType()}'.");

writer.WritePropertyName(nameof(result.IndexTimestamp));
writer.WriteString(result.IndexTimestamp.ToString(DefaultFormat.DateTimeFormatsToWrite));
writer.WriteString(result.IndexTimestamp.GetDefaultRavenFormat());
writer.WriteComma();

writer.WritePropertyName(nameof(result.LastQueryTime));
writer.WriteString(result.LastQueryTime.ToString(DefaultFormat.DateTimeFormatsToWrite));
writer.WriteString(result.LastQueryTime.GetDefaultRavenFormat());
writer.WriteComma();

writer.WritePropertyName(nameof(result.IsStale));
Expand Down
19 changes: 9 additions & 10 deletions src/Raven.Server/ServerWide/Commands/ClusterTransactionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,17 @@ internal static void ValidateCommands(ArraySegment<BatchRequestParser.CommandDat
}
break;
case CommandType.PUT:
case CommandType.DELETE:
if (document.Type == CommandType.PUT)
{
if (document.SeenAttachments)
throw new NotSupportedException($"The document {document.Id} has attachments, this is not supported in cluster wide transaction.");
if (document.SeenAttachments)
throw new NotSupportedException($"The document {document.Id} has attachments, this is not supported in cluster wide transaction.");

if (document.SeenCounters)
throw new NotSupportedException($"The document {document.Id} has counters, this is not supported in cluster wide transaction.");
if (document.SeenCounters)
throw new NotSupportedException($"The document {document.Id} has counters, this is not supported in cluster wide transaction.");

if (document.SeenTimeSeries)
throw new NotSupportedException($"The document {document.Id} has time series, this is not supported in cluster wide transaction.");
}
if (document.SeenTimeSeries)
throw new NotSupportedException($"The document {document.Id} has time series, this is not supported in cluster wide transaction.");

break;
case CommandType.DELETE:
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private void UpdateNodeReportIfNeeded(ClusterNodeStatusReport nodeReport, List<D
case ClusterNodeStatusReport.ReportStatus.HighDirtyMemory:
break;
default:
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException($"The status {lastReport.Status} is not supported.");
}

foreach (var dbReport in unchangedReports)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ export const statisticsViewSlice = createSlice({
const { initForDatabase, refreshStarted, refreshFinished } = statisticsViewSlice.actions;

export const initView = (db: DatabaseSharedInfo) => async (dispatch: AppDispatch, getState: () => RootState) => {
const firstTime = selectEssentialStats(getState()).status === "idle";
const firstTime =
selectEssentialStats(getState()).status === "idle" || db.name !== getState().statistics.databaseName;

if (firstTime) {
dispatch(initForDatabase(db.name, DatabaseUtils.getLocations(db)));
Expand Down
12 changes: 5 additions & 7 deletions test/RachisTests/DatabaseCluster/AtomicClusterReadWriteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,7 @@ public async Task CanRestoreAfterRecreation(Options options)
var backupStatus3 = await source.Maintenance.SendAsync(new StartBackupOperation(false, backupTaskId));
await backupStatus3.WaitForCompletionAsync(TimeSpan.FromMinutes(5));

var backupDir = Directory.GetDirectories(backupPath).First();
var files = Directory.GetFiles(backupDir)
.Where(BackupUtils.IsBackupFile)
.OrderBackups()
.ToArray();

Assert.Equal(3, files.Length);
var files = await Backup.GetBackupFilesAndAssertCountAsync(backupPath, 3, source.Database, backupStatus3.Id);

var smugglerOptions = new DatabaseSmugglerImportOptions();
DatabaseSmuggler.ConfigureOptionsForIncrementalImport(smugglerOptions);
Expand Down Expand Up @@ -458,6 +452,8 @@ public async Task ClusterWideTransaction_WhenRestoreFromIncrementalBackupAfterSt
var backupStatus2 = await source.Maintenance.SendAsync(new StartBackupOperation(false, backupTaskId));
await backupStatus2.WaitForCompletionAsync(TimeSpan.FromMinutes(5));

await Backup.GetBackupFilesAndAssertCountAsync(backupPath, 2, source.Database, backupStatus2.Id);

await documentStore.Smuggler.ImportIncrementalAsync(new DatabaseSmugglerImportOptions(), Directory.GetDirectories(backupPath).First());
}

Expand Down Expand Up @@ -521,6 +517,8 @@ public async Task ClusterWideTransaction_WhenRestoreFromIncrementalBackupAfterSt
var backupStatus2 = await source.Maintenance.SendAsync(new StartBackupOperation(false, backupTaskId));
await backupStatus2.WaitForCompletionAsync(TimeSpan.FromMinutes(5));

await Backup.GetBackupFilesAndAssertCountAsync(backupPath, 2, source.Database, backupStatus2.Id);

await documentStore.Smuggler.ImportIncrementalAsync(new DatabaseSmugglerImportOptions(), Directory.GetDirectories(backupPath).First());
}

Expand Down
8 changes: 4 additions & 4 deletions test/SlowTests/Cluster/ClusterTransactionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,13 +1396,13 @@ public async Task ClusterWideTransaction_WhenStoreDocWithEmptyStringId_ShouldThr
{
TransactionMode = TransactionMode.ClusterWide
});

var entity = new User { Id = id };
await session.StoreAsync(entity);
await session.SaveChangesAsync();
});
Assert.True(ContainsRachisException(e));

Assert.True(ContainsRachisException(e), e.ToString());
static bool ContainsRachisException(Exception e)
{
while (true)
Expand All @@ -1411,7 +1411,7 @@ static bool ContainsRachisException(Exception e)
return true;
if (e is AggregateException ae)
return ae.InnerExceptions.Any(ex => ContainsRachisException(ex));

if (e.InnerException == null)
return false;
e = e.InnerException;
Expand Down
2 changes: 2 additions & 0 deletions test/SlowTests/Issues/RavenDB-21050.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public async Task ClusterWideTransaction_WhenRestoreFromIncrementalBackupAfterSt
path = Directory.GetDirectories(backupPath).First(p => p.Contains($"${shardNumber}"));
}

await Backup.GetBackupFilesAndAssertCountAsync(path, 2, source.Database, backupStatus2.Id);

var restoreConfig = new RestoreBackupConfiguration { BackupLocation = path, DatabaseName = destination.Database };
using (Backup.RestoreDatabase(destination, restoreConfig))
{
Expand Down
39 changes: 39 additions & 0 deletions test/SlowTests/Issues/RavenDB_22750.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Threading.Tasks;
using FastTests;
using Raven.Client.Documents;
using SlowTests.Core.Utils.Entities;
using SlowTests.Core.Utils.Indexes;
using Tests.Infrastructure;
using Xunit;
using Xunit.Abstractions;

namespace SlowTests.Issues;

public class RavenDB_22750 : RavenTestBase
{
public RavenDB_22750(ITestOutputHelper output) : base(output)
{
}

[RavenFact(RavenTestCategory.Querying)]
public async Task IndexTimestamp_And_LastQueryTime_Needs_To_Have_DateTimeKind_Specified()
{
using (var store = GetDocumentStore())
{
await new Companies_ByEmployeeLastName().ExecuteAsync(store);

Indexes.WaitForIndexing(store);

using (var session = store.OpenAsyncSession())
{
await session.Query<Company, Companies_ByEmployeeLastName>()
.Statistics(out var stats)
.ToListAsync();

Assert.Equal(DateTimeKind.Utc, stats.IndexTimestamp.Kind);
Assert.Equal(DateTimeKind.Utc, stats.LastQueryTime.Kind);
}
}
}
}
45 changes: 45 additions & 0 deletions test/SlowTests/Issues/RavenDB_22753.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Linq;
using FastTests;
using Raven.Client;
using Raven.Client.Documents.Indexes;
using Raven.Client.Documents.Operations.Indexes;
using Raven.Tests.Core.Utils.Entities;
using Tests.Infrastructure;
using Xunit;
using Xunit.Abstractions;

namespace SlowTests.Issues;

public class RavenDB_22753 : RavenTestBase
{
public RavenDB_22753(ITestOutputHelper output) : base(output)
{
}

[RavenFact(RavenTestCategory.ClientApi | RavenTestCategory.Indexes)]
public void MustSendSearchEngineType()
{
using var store = GetDocumentStore();

IndexCreation.CreateIndexes(new []
{
new Users_ByName()
}, store);

IndexDefinition[] indexDefinitions = store.Maintenance.Send(new GetIndexesOperation(0, 1));

Assert.Contains(Constants.Configuration.Indexes.IndexingStaticSearchEngineType, (IDictionary<string, string>) indexDefinitions[0].Configuration);
Assert.Equal("Corax", indexDefinitions[0].Configuration[Constants.Configuration.Indexes.IndexingStaticSearchEngineType]);
}

private class Users_ByName : AbstractIndexCreationTask<User>
{
public Users_ByName()
{
Map = users => from u in users select new { Name = u.Name, LastName = u.LastName };

SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Corax;
}
}
}
Loading

0 comments on commit 7adfcf9

Please sign in to comment.