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

Not set creation time in integration tests #195

Open
oliverdettenborn opened this issue Sep 6, 2023 · 0 comments
Open

Not set creation time in integration tests #195

oliverdettenborn opened this issue Sep 6, 2023 · 0 comments

Comments

@oliverdettenborn
Copy link

oliverdettenborn commented Sep 6, 2023

I have create the class to use the eventuate lib on application with spring and postgressql:

@Service
@RequiredArgsConstructor
public class AbstractMessageProducer {
    private final MessageProducer messageProducer;

    protected void send(final String eventType, final Object payload) {
        final Message message = MessageBuilder
                .withPayload(JSonMapper.toJson(payload))
                .build();

        messageProducer.send(eventType, message);
    }
}

My table have the current DDL:

create table message
(
    id                varchar(767)                                                     not null,
    incremental_id    bigint   default nextval('message_incremental_id_seq'::regclass) not null,
    destination       varchar(1000)                                                    not null,
    headers           text                                                             not null,
    payload           text                                                             not null,
    published         smallint default 0,
    message_partition smallint,
    creation_time     bigint                                                           not null,
    primary key (id, creation_time)
)
    partition by RANGE (creation_time);

To validate if the AbstractMessageProducer works fine I have create this integration test:

@InfrastructureIntegrationTest
class AbstractMessageProducerIT {
    @Autowired
    private EntityManager entityManager;

    @Qualifier("abstractMessageProducer")
    @Autowired
    private AbstractMessageProducer abstractMessageProducer;

    @Test
    void shouldAddOnMessageTableTheEvent() {
        final var payload = UpsertPropertyDTO.builder()
                .eventType("UPDATE_PROPERTY")
                .payload(UpsertExternalHouseDTO.builder().build())
                .build();

        abstractMessageProducer.send(payload.getEventType(), payload.getPayload());

        final var result = entityManager
                .createNativeQuery("SELECT * FROM message", String.class)
                .getResultList();

        assertEquals(1, result.size());
    }
}

My integration test use test-container DB to run this test and apply the migration on db with flyway. But this test failed with error:

PreparedStatementCallback; SQL [insert into message(id, destination, headers, payload, creation_time, published, message_partition) values(?, ?, ?, ?, null, ?, ?)]; ERROR: no partition of relation "message" found for row
  Detalhe: Partition key of the failing row contains (creation_time) = (null).
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into message(id, destination, headers, payload, creation_time, published, message_partition) values(?, ?, ?, ?, null, ?, ?)]; ERROR: no partition of relation "message" found for row

Where eventuate lib not set value for creation_time. Do you guys know what happens here?

@oliverdettenborn oliverdettenborn changed the title Eventuae no set creation time in integration tests Not set creation time in integration tests Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant