use of org.bf2.cos.fleetshard.api.ManagedConnectorStatusBuilder in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ConnectorStatusExtractorTest method extractFromConnectorStatus.
/*
* Test that if the status sub resource is provided and the phase is
* "monitor", then the status extractor compute the phase according
* to the reported deployment status
*/
@ParameterizedTest
@MethodSource
void extractFromConnectorStatus(String statusDesiredState, String connectorPhase, String expectedState, List<Condition> conditions) {
var status = ConnectorStatusExtractor.extract(new ManagedConnectorBuilder().withSpec(new ManagedConnectorSpecBuilder().withOperatorSelector(new OperatorSelectorBuilder().withId("1").build()).build()).withStatus(new ManagedConnectorStatusBuilder().withPhase(ManagedConnectorStatus.PhaseType.Monitor).withDeployment(new DeploymentSpecBuilder().withDeploymentResourceVersion(1L).withDesiredState(statusDesiredState).build()).withConnectorStatus(new ConnectorStatusSpecBuilder().withPhase(connectorPhase).withConditions(conditions).build()).build()).build());
var v1Conditions = conditions.stream().map(ConnectorStatusExtractor::toMetaV1Condition).collect(Collectors.toList());
assertThat(status.getPhase()).isEqualTo(expectedState);
assertThat(status.getConditions()).hasSameSizeAs(conditions).hasSameElementsAs(v1Conditions);
assertThat(status.getResourceVersion()).isEqualTo(1L);
assertThat(status).extracting(ConnectorDeploymentStatus::getOperators).extracting(ConnectorDeploymentStatusOperators::getAssigned).hasAllNullFieldsOrProperties();
assertThat(status).extracting(ConnectorDeploymentStatus::getOperators).extracting(ConnectorDeploymentStatusOperators::getAvailable).hasAllNullFieldsOrProperties();
}
use of org.bf2.cos.fleetshard.api.ManagedConnectorStatusBuilder in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ConnectorStatusExtractorTest method errorIfNoOperatorId.
@Test
void errorIfNoOperatorId() {
var status = ConnectorStatusExtractor.extract(new ManagedConnectorBuilder().withSpec(new ManagedConnectorSpecBuilder().withOperatorSelector(new OperatorSelectorBuilder().build()).build()).withStatus(new ManagedConnectorStatusBuilder().withPhase(ManagedConnectorStatus.PhaseType.Monitor).withDeployment(new DeploymentSpecBuilder().withDeploymentResourceVersion(1L).withDesiredState(DESIRED_STATE_READY).build()).build()).build());
assertThat(status.getPhase()).isEqualTo(ConnectorState.FAILED);
assertThat(status.getConditions()).anySatisfy(c -> {
assertThat(c.getType()).isEqualTo(Conditions.TYPE_READY);
assertThat(c.getStatus()).isEqualTo(Conditions.STATUS_FALSE);
assertThat(c.getReason()).isEqualTo(Conditions.NO_ASSIGNABLE_OPERATOR_REASON);
});
assertThat(status.getResourceVersion()).isEqualTo(1L);
}
use of org.bf2.cos.fleetshard.api.ManagedConnectorStatusBuilder in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ConnectorStatusExtractorTest method errorIfNoOperatorSelector.
@Test
void errorIfNoOperatorSelector() {
var status = ConnectorStatusExtractor.extract(new ManagedConnectorBuilder().withSpec(new ManagedConnectorSpecBuilder().build()).withStatus(new ManagedConnectorStatusBuilder().withPhase(ManagedConnectorStatus.PhaseType.Monitor).withDeployment(new DeploymentSpecBuilder().withDeploymentResourceVersion(1L).withDesiredState(DESIRED_STATE_READY).build()).build()).build());
assertThat(status.getPhase()).isEqualTo(ConnectorState.FAILED);
assertThat(status.getConditions()).anySatisfy(c -> {
assertThat(c.getType()).isEqualTo(Conditions.TYPE_READY);
assertThat(c.getStatus()).isEqualTo(Conditions.STATUS_FALSE);
assertThat(c.getReason()).isEqualTo(Conditions.NO_ASSIGNABLE_OPERATOR_REASON);
});
assertThat(status.getResourceVersion()).isEqualTo(1L);
}
use of org.bf2.cos.fleetshard.api.ManagedConnectorStatusBuilder in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ConnectorStatusExtractorTest method extractFromConnectorStatus.
/*
* Test that if the status sub resource is provided and the phase is
* "monitor", then the status extractor compute the phase according
* to the reported deployment status
*/
@ParameterizedTest
@MethodSource
void extractFromConnectorStatus(String statusDesiredState, String connectorPhase, ConnectorState expectedState, List<Condition> conditions) {
var status = ConnectorStatusExtractor.extract(new ManagedConnectorBuilder().withSpec(new ManagedConnectorSpecBuilder().withOperatorSelector(new OperatorSelectorBuilder().withId("1").build()).build()).withStatus(new ManagedConnectorStatusBuilder().withPhase(ManagedConnectorStatus.PhaseType.Monitor).withDeployment(new DeploymentSpecBuilder().withDeploymentResourceVersion(1L).withDesiredState(statusDesiredState).build()).withConnectorStatus(new ConnectorStatusSpecBuilder().withPhase(connectorPhase).withConditions(conditions).build()).build()).build());
var v1Conditions = conditions.stream().map(ConnectorStatusExtractor::toMetaV1Condition).collect(Collectors.toList());
assertThat(status.getPhase()).isEqualTo(expectedState);
assertThat(status.getConditions()).hasSameSizeAs(conditions).hasSameElementsAs(v1Conditions);
assertThat(status.getResourceVersion()).isEqualTo(1L);
assertThat(status).extracting(ConnectorDeploymentStatus::getOperators).extracting(ConnectorDeploymentStatusOperators::getAssigned).hasAllNullFieldsOrProperties();
assertThat(status).extracting(ConnectorDeploymentStatus::getOperators).extracting(ConnectorDeploymentStatusOperators::getAvailable).hasAllNullFieldsOrProperties();
}
Aggregations