Skip to content

Commit

Permalink
merge: #10458
Browse files Browse the repository at this point in the history
10458: Reorganize stream processor and engine tests r=Zelldon a=Zelldon

## Description

Moved some tests around to make it easier to detect which need to be migrated for #10455 and to make it easier to create the new module and copy the tests, which are part of the StreamProcessor see #10130 

<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

related to #10455 
related to #10130 




Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and Zelldon committed Sep 29, 2022
2 parents 2c5a067 + 78266e9 commit 69d32be
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.processing;

import io.camunda.zeebe.engine.state.ZbColumnFamilies;
import io.camunda.zeebe.engine.util.EngineRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.processing.randomized;

import io.camunda.zeebe.test.util.bpmn.random.TestDataGenerator.TestDataRecord;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.processing.randomized;

import io.camunda.zeebe.engine.util.EngineRule;
import io.camunda.zeebe.engine.util.ProcessExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.processing.randomized;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.state;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.engine.state;

import static org.assertj.core.api.Assertions.assertThat;

import io.camunda.zeebe.engine.processing.message.MessageObserver;
import io.camunda.zeebe.engine.state.ZbColumnFamilies;
import io.camunda.zeebe.engine.util.EngineRule;
import io.camunda.zeebe.model.bpmn.Bpmn;
import io.camunda.zeebe.model.bpmn.BpmnModelInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.streamprocessor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import io.camunda.zeebe.logstreams.log.LoggedEvent;
import io.camunda.zeebe.streamprocessor.EventFilter;
import org.junit.Test;

public final class EventFilterTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.streamprocessor;

import static io.camunda.zeebe.engine.util.RecordToWrite.command;
import static io.camunda.zeebe.engine.util.RecordToWrite.event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.streamprocessor;

import static io.camunda.zeebe.engine.util.RecordToWrite.command;
import static io.camunda.zeebe.engine.util.RecordToWrite.event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.engine.processing.streamprocessor;
package io.camunda.zeebe.streamprocessor;

import static io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent.ACTIVATE_ELEMENT;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -34,7 +34,6 @@
import io.camunda.zeebe.scheduler.clock.ControlledActorClock;
import io.camunda.zeebe.scheduler.future.ActorFuture;
import io.camunda.zeebe.scheduler.future.CompletableActorFuture;
import io.camunda.zeebe.streamprocessor.ProcessingScheduleServiceImpl;
import io.camunda.zeebe.streamprocessor.StreamProcessor.Phase;
import io.camunda.zeebe.test.util.junit.RegressionTest;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.streamprocessor;

import static io.camunda.zeebe.util.buffer.BufferUtil.wrapString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import io.camunda.zeebe.engine.api.TypedRecord;
import io.camunda.zeebe.logstreams.log.LoggedEvent;
import io.camunda.zeebe.protocol.impl.record.CopiedRecord;
import io.camunda.zeebe.protocol.impl.record.RecordMetadata;
import io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord;
import io.camunda.zeebe.protocol.record.RecordType;
import io.camunda.zeebe.protocol.record.RejectionType;
import io.camunda.zeebe.protocol.record.ValueType;
import io.camunda.zeebe.protocol.record.intent.DeploymentIntent;
import io.camunda.zeebe.test.util.JsonUtil;
import io.camunda.zeebe.util.collection.Tuple;
import org.agrona.DirectBuffer;
import org.junit.Test;

public final class TypedEventSerializationTest {

private static Tuple<TypedRecord, CopiedRecord> createRecordTuple() {
final RecordMetadata recordMetadata = new RecordMetadata();

final DeploymentIntent intent = DeploymentIntent.CREATE;
final int protocolVersion = 1;
final ValueType valueType = ValueType.DEPLOYMENT;

final RecordType recordType = RecordType.COMMAND;
final String rejectionReason = "fails";
final RejectionType rejectionType = RejectionType.INVALID_ARGUMENT;
final int requestId = 23;
final int requestStreamId = 1;

recordMetadata
.intent(intent)
.protocolVersion(protocolVersion)
.valueType(valueType)
.recordType(recordType)
.rejectionReason(rejectionReason)
.rejectionType(rejectionType)
.requestId(requestId)
.requestStreamId(requestStreamId);

final String resourceName = "resource";
final DirectBuffer resource = wrapString("contents");
final String bpmnProcessId = "testProcess";
final long processDefinitionKey = 123;
final int processVersion = 12;
final DeploymentRecord record = new DeploymentRecord();
record.resources().add().setResourceName(wrapString(resourceName)).setResource(resource);
record
.processesMetadata()
.add()
.setBpmnProcessId(wrapString(bpmnProcessId))
.setKey(processDefinitionKey)
.setResourceName(wrapString(resourceName))
.setVersion(processVersion)
.setChecksum(wrapString("checksum"));

final long key = 1234;
final long position = 4321;
final long sourcePosition = 231;
final long timestamp = 2191L;

final LoggedEvent loggedEvent = mock(LoggedEvent.class);
when(loggedEvent.getPosition()).thenReturn(position);
when(loggedEvent.getKey()).thenReturn(key);
when(loggedEvent.getSourceEventPosition()).thenReturn(sourcePosition);
when(loggedEvent.getTimestamp()).thenReturn(timestamp);

final TypedRecordImpl typedEvent = new TypedRecordImpl(0);
typedEvent.wrap(loggedEvent, recordMetadata, record);

final CopiedRecord copiedRecord =
new CopiedRecord<>(record, recordMetadata, key, 0, position, sourcePosition, timestamp);

return new Tuple<>(typedEvent, copiedRecord);
}

@Test
public void shouldCreateSameJson() {
// given
final Tuple<TypedRecord, CopiedRecord> records = createRecordTuple();
final String expectedJson = records.getRight().toJson();

// when
final String actualJson = records.getLeft().toJson();

// then
JsonUtil.assertEquality(actualJson, expectedJson);
}
}

0 comments on commit 69d32be

Please sign in to comment.