Skip to content

Commit

Permalink
Do NOT disable faulty endpoints by default (RedHatInsights#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenneg authored Mar 19, 2024
1 parent c331e4e commit a285a8a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .rhcicd/clowdapp-connector-google-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ parameters:
value: INFO
- name: NOTIFICATIONS_CONNECTOR_HTTP_DISABLE_FAULTY_ENDPOINTS
description: Add flags on connector response to let engine disable endpoint regarding HTTP error type
value: "true"
value: "false"
- name: NOTIFICATIONS_UNLEASH_ENABLED
value: "false"
- name: QUARKUS_HTTP_PORT
Expand Down
2 changes: 1 addition & 1 deletion .rhcicd/clowdapp-connector-microsoft-teams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ parameters:
value: INFO
- name: NOTIFICATIONS_CONNECTOR_HTTP_DISABLE_FAULTY_ENDPOINTS
description: Add flags on connector response to let engine disable endpoint regarding HTTP error type
value: "true"
value: "false"
- name: NOTIFICATIONS_UNLEASH_ENABLED
value: "false"
- name: QUARKUS_HTTP_PORT
Expand Down
2 changes: 1 addition & 1 deletion .rhcicd/clowdapp-connector-servicenow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ parameters:
value: INFO
- name: NOTIFICATIONS_CONNECTOR_HTTP_DISABLE_FAULTY_ENDPOINTS
description: Add flags on connector response to let engine disable endpoint regarding HTTP error type
value: "true"
value: "false"
- name: NOTIFICATIONS_UNLEASH_ENABLED
value: "false"
- name: QUARKUS_HTTP_PORT
Expand Down
2 changes: 1 addition & 1 deletion .rhcicd/clowdapp-connector-splunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ parameters:
value: INFO
- name: NOTIFICATIONS_CONNECTOR_HTTP_DISABLE_FAULTY_ENDPOINTS
description: Add flags on connector response to let engine disable endpoint regarding HTTP error type
value: "true"
value: "false"
- name: NOTIFICATIONS_UNLEASH_ENABLED
value: "false"
- name: QUARKUS_HTTP_PORT
Expand Down
2 changes: 1 addition & 1 deletion .rhcicd/clowdapp-connector-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ parameters:
value: INFO
- name: NOTIFICATIONS_CONNECTOR_HTTP_DISABLE_FAULTY_ENDPOINTS
description: Add flags on connector response to let engine disable endpoint regarding HTTP error type
value: "true"
value: "false"
- name: NOTIFICATIONS_UNLEASH_ENABLED
value: "false"
- name: QUARKUS_HTTP_PORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class HttpConnectorConfig extends ConnectorConfig {
@ConfigProperty(name = CONNECTIONS_PER_ROUTE, defaultValue = "20")
int httpConnectionsPerRoute;

@ConfigProperty(name = DISABLE_FAULTY_ENDPOINTS, defaultValue = "true")
@ConfigProperty(name = DISABLE_FAULTY_ENDPOINTS, defaultValue = "false")
@Deprecated(forRemoval = true, since = "To be removed when we're done migrating to Unleash in all environments")
boolean disableFaultyEndpoints;

Expand Down Expand Up @@ -108,6 +108,11 @@ public boolean isDisableFaultyEndpoints() {
}
}

@Deprecated(forRemoval = true)
public void setDisableFaultyEndpoints(boolean disableFaultyEndpoints) {
this.disableFaultyEndpoints = disableFaultyEndpoints;
}

public boolean isFollowRedirects() {
return followRedirects;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import com.redhat.cloud.notifications.connector.TestLifecycleManager;
import com.redhat.cloud.notifications.connector.authentication.AuthenticationType;
import com.redhat.cloud.notifications.connector.authentication.secrets.SecretsLoader;
import com.redhat.cloud.notifications.connector.http.HttpConnectorConfig;
import io.quarkus.test.InjectMock;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.vertx.core.json.JsonObject;
import jakarta.inject.Inject;
import org.apache.camel.Exchange;
import org.apache.camel.Predicate;
import org.apache.camel.component.mock.MockEndpoint;
Expand Down Expand Up @@ -40,6 +42,9 @@ class WebhookConnectorRoutesTest extends ConnectorRoutesTest {
@InjectMock
SecretsLoader secretsLoader;

@Inject
HttpConnectorConfig connectorConfig;

@Override
protected String getMockEndpointPattern() {
return "https://foo.bar";
Expand Down Expand Up @@ -139,12 +144,17 @@ protected void testFailedNotificationError404() throws Exception {
}

private void testFailedNotificationAndReturnedFlagsToEngine(int httpReturnCode, String returnedBodyMessage, String flagNameThatShouldBeTrue, final int expectedRedeliveriesCount) throws Exception {
mockRemoteServerError(httpReturnCode, returnedBodyMessage);
JsonObject returnToEngine = super.testFailedNotification(expectedRedeliveriesCount);
JsonObject data = new JsonObject(returnToEngine.getString("data"));
assertTrue(data.getBoolean(flagNameThatShouldBeTrue));
JsonObject details = data.getJsonObject("details");
assertEquals(httpReturnCode, details.getInteger(HTTP_STATUS_CODE));
connectorConfig.setDisableFaultyEndpoints(true);
try {
mockRemoteServerError(httpReturnCode, returnedBodyMessage);
JsonObject returnToEngine = super.testFailedNotification(expectedRedeliveriesCount);
JsonObject data = new JsonObject(returnToEngine.getString("data"));
assertTrue(data.getBoolean(flagNameThatShouldBeTrue));
JsonObject details = data.getJsonObject("details");
assertEquals(httpReturnCode, details.getInteger(HTTP_STATUS_CODE));
} finally {
connectorConfig.setDisableFaultyEndpoints(false);
}
}

@Test
Expand Down

0 comments on commit a285a8a

Please sign in to comment.