Skip to content

Commit

Permalink
[MO] - [unit + integration co tests] -> method wide parallelism (#4860)
Browse files Browse the repository at this point in the history
* [MO] - [unit + integration co tests] -> method wide parallelism

Signed-off-by: morsak <[email protected]>

* fixes + checkstyle + some race codnitions

Signed-off-by: morsak <[email protected]>

* fixed race conditions of KafkaAssemblOperatorTest

Signed-off-by: morsak <[email protected]>

* race conditions fixed in KafkaAssemblyOperatorMockTest

Signed-off-by: morsak <[email protected]>

* changes needed after rebase

Signed-off-by: morsak <[email protected]>
  • Loading branch information
see-quick authored May 7, 2021
1 parent 364978f commit 8e63188
Show file tree
Hide file tree
Showing 31 changed files with 627 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import io.strimzi.operator.common.operator.resource.SecretOperator;
import io.strimzi.test.TestUtils;

import io.strimzi.test.annotations.ParallelSuite;
import io.strimzi.test.annotations.ParallelTest;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
Expand All @@ -41,7 +43,6 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;

Expand Down Expand Up @@ -89,6 +90,7 @@
import static org.mockito.Mockito.when;

@ExtendWith(VertxExtension.class)
@ParallelSuite
public class CertificateRenewalTest {

public static final String NAMESPACE = "test";
Expand Down Expand Up @@ -250,7 +252,7 @@ private X509Certificate getCertificateFromTrustStore(String alias, Map<String, S
}


@Test
@ParallelTest
public void testReconcileCasGeneratesCertsInitially(VertxTestContext context) {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
.withValidityDays(100)
Expand Down Expand Up @@ -280,7 +282,7 @@ public void testReconcileCasGeneratesCertsInitially(VertxTestContext context) {
})));
}

@Test
@ParallelTest
public void testReconcileCasWhenCustomCertsAreMissingThrows(VertxTestContext context) {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
.withValidityDays(100)
Expand All @@ -297,7 +299,7 @@ public void testReconcileCasWhenCustomCertsAreMissingThrows(VertxTestContext con
})));
}

@Test
@ParallelTest
public void testReconcileCasNoCertsGetGeneratedOutsideRenewalPeriod(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
assertNoCertsGetGeneratedOutsideRenewalPeriod(context, true);
Expand Down Expand Up @@ -373,7 +375,7 @@ private void assertNoCertsGetGeneratedOutsideRenewalPeriod(VertxTestContext cont

}

@Test
@ParallelTest
public void testGenerateTruststoreFromOldSecrets(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -449,7 +451,7 @@ public void testGenerateTruststoreFromOldSecrets(VertxTestContext context)
})));
}

@Test
@ParallelTest
public void testNewCertsGetGeneratedWhenInRenewalPeriodAuto(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -534,7 +536,7 @@ public void testNewCertsGetGeneratedWhenInRenewalPeriodAuto(VertxTestContext con
})));
}

@Test
@ParallelTest
public void testNewCertsGetGeneratedWhenInRenewalPeriodAutoOutsideOfMaintenanceWindow(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -635,7 +637,7 @@ public void testNewCertsGetGeneratedWhenInRenewalPeriodAutoOutsideOfMaintenanceW
})));
}

@Test
@ParallelTest
public void testNewCertsGetGeneratedWhenInRenewalPeriodAutoWithinMaintenanceWindow(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -735,7 +737,7 @@ public void testNewCertsGetGeneratedWhenInRenewalPeriodAutoWithinMaintenanceWind
})));
}

@Test
@ParallelTest
public void testNewKeyGetGeneratedWhenInRenewalPeriodAuto(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -838,7 +840,7 @@ public void testNewKeyGetGeneratedWhenInRenewalPeriodAuto(VertxTestContext conte
})));
}

@Test
@ParallelTest
public void testNewKeyGeneratedWhenInRenewalPeriodAutoOutsideOfTimeWindow(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -938,7 +940,7 @@ public void testNewKeyGeneratedWhenInRenewalPeriodAutoOutsideOfTimeWindow(VertxT
})));
}

@Test
@ParallelTest
public void testNewKeyGeneratedWhenInRenewalPeriodAutoWithinTimeWindow(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -1062,7 +1064,7 @@ private X509Certificate x509Certificate(String newClusterCaCert) throws Certific
.generateCertificate(new ByteArrayInputStream(Base64.getDecoder().decode(newClusterCaCert)));
}

@Test
@ParallelTest
public void testExpiredCertsGetRemovedAuto(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -1158,7 +1160,7 @@ public void testExpiredCertsGetRemovedAuto(VertxTestContext context)
})));
}

@Test
@ParallelTest
public void testCustomCertsNotReconciled(VertxTestContext context)
throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
CertificateAuthority certificateAuthority = new CertificateAuthorityBuilder()
Expand Down Expand Up @@ -1202,7 +1204,7 @@ public void testCustomCertsNotReconciled(VertxTestContext context)
})));
}

@Test
@ParallelTest
public void testRenewalOfDeploymentCertificatesWithNullSecret() throws IOException {
CertAndKey newCertAndKey = new CertAndKey("new-key".getBytes(), "new-cert".getBytes(), "new-truststore".getBytes(), "new-keystore".getBytes(), "new-password");
ClusterCa clusterCaMock = mock(ClusterCa.class);
Expand All @@ -1224,7 +1226,7 @@ public void testRenewalOfDeploymentCertificatesWithNullSecret() throws IOExcepti
assertThat(newSecret.getData(), hasEntry("deployment.password", newCertAndKey.storePasswordAsBase64String()));
}

@Test
@ParallelTest
public void testRenewalOfDeploymentCertificatesWithRenewingCa() throws IOException {
Secret initialSecret = new SecretBuilder()
.withNewMetadata()
Expand Down Expand Up @@ -1258,7 +1260,7 @@ public void testRenewalOfDeploymentCertificatesWithRenewingCa() throws IOExcepti
assertThat(newSecret.getData(), hasEntry("deployment.password", newCertAndKey.storePasswordAsBase64String()));
}

@Test
@ParallelTest
public void testRenewalOfDeploymentCertificatesDelayedRenewal() throws IOException {
Secret initialSecret = new SecretBuilder()
.withNewMetadata()
Expand Down Expand Up @@ -1292,7 +1294,7 @@ public void testRenewalOfDeploymentCertificatesDelayedRenewal() throws IOExcepti
assertThat(newSecret.getData(), hasEntry("deployment.password", newCertAndKey.storePasswordAsBase64String()));
}

@Test
@ParallelTest
public void testRenewalOfDeploymentCertificatesDelayedRenewalOutsideOfMaintenanceWindow() throws IOException {
Secret initialSecret = new SecretBuilder()
.withNewMetadata()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import io.strimzi.operator.common.model.OrderedProperties;
import io.strimzi.operator.common.operator.resource.SecretOperator;
import io.strimzi.test.TestUtils;
import io.strimzi.test.annotations.IsolatedTest;
import io.strimzi.test.annotations.ParallelTest;
import io.strimzi.test.mockkube.MockKube;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
Expand All @@ -50,7 +52,6 @@
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.util.Collections;
Expand Down Expand Up @@ -444,7 +445,7 @@ public void waitForConnectorNotReady(String connectorName, String reason, String
ConnectorMockTest.<KafkaConnector>statusIsForCurrentGeneration().and(notReady(reason, message)));
}

@Test
@ParallelTest
public void testConnectNotReadyWithoutSpec() {
String connectName = "cluster";
KafkaConnect connect = new KafkaConnectBuilder()
Expand All @@ -458,7 +459,7 @@ public void testConnectNotReadyWithoutSpec() {
waitForConnectNotReady(connectName, "InvalidResourceException", "Spec cannot be null");
}

@Test
@ParallelTest
public void testConnectorNotReadyWithoutStrimziClusterLabel() {
String connectorName = "connector";

Expand All @@ -476,7 +477,7 @@ public void testConnectorNotReadyWithoutStrimziClusterLabel() {
"Resource lacks label '" + Labels.STRIMZI_CLUSTER_LABEL + "': No connect cluster in which to create this connector.");
}

@Test
@ParallelTest
public void testConnectorNotReadyWhenConnectDoesNotExist() {
String connectorName = "connector";

Expand All @@ -492,7 +493,7 @@ public void testConnectorNotReadyWhenConnectDoesNotExist() {
"KafkaConnect resource 'cluster' identified by label '" + Labels.STRIMZI_CLUSTER_LABEL + "' does not exist in namespace ns.");
}

@Test
@ParallelTest
public void testConnectorNotReadyWithoutSpec() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -521,7 +522,7 @@ public void testConnectorNotReadyWithoutSpec() {
waitForConnectorNotReady(connectorName, "InvalidResourceException", "spec property is required");
}

@Test
@ParallelTest
public void testConnectorNotReadyWhenConnectNotConfiguredForConnectors() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -552,7 +553,7 @@ public void testConnectorNotReadyWhenConnectNotConfiguredForConnectors() {
}

/** Create connect, create connector, delete connector, delete connect */
@Test
@ParallelTest
public void testConnectConnectorConnectorConnect() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -616,7 +617,7 @@ public void testConnectConnectorConnectorConnect() {
}

/** Create connector, create connect, delete connector, delete connect */
@Test
@IsolatedTest
public void testConnectorConnectConnectorConnect() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -677,7 +678,7 @@ public void testConnectorConnectConnectorConnect() {
}

/** Create connect, create connector, delete connect, delete connector */
@Test
@ParallelTest
public void testConnectConnectorConnectConnector() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -741,7 +742,7 @@ public void testConnectConnectorConnectConnector() {
}

/** Create connector, create connect, delete connect, delete connector */
@Test
@ParallelTest
public void testConnectorConnectConnectConnector() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -808,7 +809,7 @@ public void testConnectorConnectConnectConnector() {
* check the connector is deleted from the old cluster
* check the connector is added to the new cluster
* */
@Test
@ParallelTest
public void testChangeStrimziClusterLabel(VertxTestContext context) throws InterruptedException {
String oldConnectClusterName = "cluster1";
String newConnectClusterName = "cluster2";
Expand Down Expand Up @@ -900,7 +901,7 @@ public void testChangeStrimziClusterLabel(VertxTestContext context) throws Inter
}

/** Create connect, create connector, delete connector, delete connect */
@Test
@IsolatedTest
public void testConnectorNotReadyWhenExceptionFromConnectRestApi() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -955,7 +956,7 @@ public void testConnectorNotReadyWhenExceptionFromConnectRestApi() {
}

/** Create connect, create connector, pause connector, resume connector */
@Test
@ParallelTest
public void testConnectorPauseResume() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1043,7 +1044,7 @@ public void testConnectorPauseResume() {
}

/** Create connect, create connector, restart connector */
@Test
@ParallelTest
public void testConnectorRestart() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1117,7 +1118,7 @@ public void testConnectorRestart() {


/** Create connect, create connector, add restart annotation, fail to restart connector, check for condition */
@Test
@ParallelTest
public void testConnectorRestartFail() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1195,7 +1196,7 @@ public void testConnectorRestartFail() {


/** Create connect, create connector, restart connector task */
@Test
@ParallelTest
public void testConnectorRestartTask() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1268,7 +1269,7 @@ public void testConnectorRestartTask() {
}

/** Create connect, create connector, restart connector task */
@Test
@ParallelTest
public void testConnectorRestartTaskFail() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1345,7 +1346,7 @@ public void testConnectorRestartTaskFail() {
}

/** Create connect, create connector, Scale to 0 */
@Test
@ParallelTest
public void testConnectScaleToZero() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1411,7 +1412,7 @@ public void testConnectScaleToZero() {
}

/** Create connect, create connector, break the REST API */
@Test
@ParallelTest
public void testConnectRestAPIIssues() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1478,7 +1479,7 @@ public void testConnectRestAPIIssues() {
waitForConnectorNotReady(connectorName, "ConnectTimeoutException", "connection timed out");
}

@Test
@ParallelTest
public void testConnectorUnknownField() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down Expand Up @@ -1519,7 +1520,7 @@ public void testConnectorUnknownField() {
waitForConnectorCondition(connectorName, "Warning", "UnknownFields");
}

@Test
@ParallelTest
public void testConnectorReconciliationPausedUnpaused() {
String connectName = "cluster";
String connectorName = "connector";
Expand Down
Loading

0 comments on commit 8e63188

Please sign in to comment.