public async Task CheckpointUpdateDoesNotInterfereWithOtherNamespaces() { var storageManager = new InMemoryStorageManager(); var mockEvent = new MockEventData( eventBody: Array.Empty <byte>(), offset: 10, sequenceNumber: 20); await storageManager.UpdateCheckpointAsync(new EventProcessorCheckpoint { FullyQualifiedNamespace = "namespace1", EventHubName = "eventHubName", ConsumerGroup = "consumerGroup", PartitionId = "partitionId" }, mockEvent); await storageManager.UpdateCheckpointAsync(new EventProcessorCheckpoint { FullyQualifiedNamespace = "namespace2", EventHubName = "eventHubName", ConsumerGroup = "consumerGroup", PartitionId = "partitionId" }, mockEvent); IEnumerable <EventProcessorCheckpoint> storedCheckpointsList1 = await storageManager.ListCheckpointsAsync("namespace1", "eventHubName", "consumerGroup"); IEnumerable <EventProcessorCheckpoint> storedCheckpointsList2 = await storageManager.ListCheckpointsAsync("namespace2", "eventHubName", "consumerGroup"); Assert.That(storedCheckpointsList1, Is.Not.Null); Assert.That(storedCheckpointsList1.Count, Is.EqualTo(1)); Assert.That(storedCheckpointsList2, Is.Not.Null); Assert.That(storedCheckpointsList2.Count, Is.EqualTo(1)); }
public void IsEquivalentToDetectsWhenOneTypedSystemPropertyIsNull() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstEvent = new MockEventData((byte[])body.Clone(), partitionKey: null); var secondEvent = new MockEventData((byte[])body.Clone(), partitionKey: "trackOne"); Assert.That(firstEvent.IsEquivalentTo(secondEvent, true), Is.False); }
public void IsEquivalentToDetectsDifferentTypedSystemProperties() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstEvent = new MockEventData((byte[])body.Clone(), offset: 1); var secondEvent = new MockEventData((byte[])body.Clone(), offset: 2); Assert.That(firstEvent.IsEquivalentTo(secondEvent, true), Is.False); }
public void IsEquivalentToIgnoresTypedSystemPropertiesByDefault() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstEvent = new MockEventData((byte[])body.Clone(), partitionKey: "1"); var secondEvent = new MockEventData((byte[])body.Clone(), partitionKey: "2"); Assert.That(firstEvent.IsEquivalentTo(secondEvent), Is.True); }
public void IsEquivalentToDetectsWhenOnePropertySetIsNull() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstEvent = new MockEventData((byte[])body.Clone(), properties: null); var secondEvent = new MockEventData((byte[])body.Clone()); secondEvent.Properties["test"] = "trackTwo"; Assert.That(firstEvent.IsEquivalentTo(secondEvent), Is.False); }
public void IsEquivalentToDetectsNullArgument() { var firstEvent = new MockEventData( eventBody: new byte[] { 0x22, 0x44, 0x88 }, offset: 1, partitionKey: "hello", systemProperties: new Dictionary <string, object> { { "test", new object() } }); Assert.That(firstEvent.IsEquivalentTo((EventData)null), Is.False); }
public void IsEquivalentToDetectsDifferentMappedSystemProperties() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstSystemProperties = new Dictionary <string, object>(); var secondSystemProperties = new Dictionary <string, object>(); var firstEvent = new MockEventData((byte[])body.Clone(), systemProperties: firstSystemProperties); var secondEvent = new MockEventData((byte[])body.Clone(), systemProperties: secondSystemProperties); firstSystemProperties[nameof(IsEquivalentToDetectsDifferentMappedSystemProperties)] = true; secondSystemProperties[nameof(IsEquivalentToDetectsDifferentMappedSystemProperties)] = false; Assert.That(firstEvent.IsEquivalentTo(secondEvent, true), Is.False); }
public void IsEquivalentToDetectsDifferentDifferentPartitionKey() { var firstEvent = new MockEventData( eventBody: new byte[] { 0x22, 0x44 }, offset: 1, partitionKey: "hello", systemProperties: new Dictionary <string, object> { { "test", new object() } }); var secondEvent = new MockEventData( eventBody: new byte[] { 0x22, 0x44 }, offset: 1, partitionKey: "goodbye", systemProperties: new Dictionary <string, object> { { "test", new object() } }); Assert.That(firstEvent.IsEquivalentTo(secondEvent, true), Is.False); }
public void IsEquivalentToDetectsEqualEventsWithoutPartitionMetrics() { var body = new byte[] { 0x22, 0x44, 0x88 }; var firstEvent = new MockEventData( eventBody: (byte[])body.Clone(), offset: 1, partitionKey: "hello", systemProperties: new Dictionary <string, object> { { "test", new object() } }); var secondEvent = new MockEventData( eventBody: (byte[])body.Clone(), offset: 1, partitionKey: "hello", systemProperties: new Dictionary <string, object> { { "test", new object() } }); Assert.That(firstEvent.IsEquivalentTo(secondEvent), Is.True); }
public async Task CheckpointUpdatesAnExistingBlob() { await using (StorageScope storageScope = await StorageScope.CreateAsync()) { var storageConnectionString = StorageTestEnvironment.Instance.StorageConnectionString; var containerClient = new BlobContainerClient(storageConnectionString, storageScope.ContainerName); var checkpointStore = new BlobCheckpointStoreInternal(containerClient); var checkpoint = new EventProcessorCheckpoint { FullyQualifiedNamespace = "namespace", EventHubName = "eventHubName", ConsumerGroup = "consumerGroup", PartitionId = "partitionId" }; var mockEvent = new MockEventData( eventBody: Array.Empty <byte>(), offset: 10, sequenceNumber: 20); // Calling update should create the checkpoint. await checkpointStore.UpdateCheckpointAsync(checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, checkpoint.PartitionId, mockEvent.Offset, mockEvent.SequenceNumber, default); var blobCount = 0; var storedCheckpoint = await checkpointStore.GetCheckpointAsync(checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, checkpoint.PartitionId, default); await foreach (var blob in containerClient.GetBlobsAsync()) { ++blobCount; if (blobCount > 1) { break; } } Assert.That(blobCount, Is.EqualTo(1)); Assert.That(storedCheckpoint, Is.Not.Null); Assert.That(storedCheckpoint.StartingPosition, Is.EqualTo(EventPosition.FromOffset(mockEvent.Offset, false))); // Calling update again should update the existing checkpoint. mockEvent = new MockEventData( eventBody: Array.Empty <byte>(), offset: 50, sequenceNumber: 60); await checkpointStore.UpdateCheckpointAsync(checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, checkpoint.PartitionId, mockEvent.Offset, mockEvent.SequenceNumber, default); blobCount = 0; storedCheckpoint = await checkpointStore.GetCheckpointAsync(checkpoint.FullyQualifiedNamespace, checkpoint.EventHubName, checkpoint.ConsumerGroup, checkpoint.PartitionId, default); await foreach (var blob in containerClient.GetBlobsAsync()) { ++blobCount; if (blobCount > 1) { break; } } Assert.That(blobCount, Is.EqualTo(1)); Assert.That(storedCheckpoint, Is.Not.Null); Assert.That(storedCheckpoint.StartingPosition, Is.EqualTo(EventPosition.FromOffset(mockEvent.Offset, false))); } }