Merge pull request #31916 from appsmithorg/release

19/03 Daily Promotion(attempt 2)
This commit is contained in:
Trisha Anand 2024-03-19 14:44:48 +05:30 committed by GitHub
commit 2270303a52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 71 additions and 2 deletions

View File

@ -145,9 +145,10 @@ jobs:
sudo /etc/init.d/ssh stop ;
mkdir -p ~/git-server/keys
mkdir -p ~/git-server/repos
ted_tag="${{inputs.ted_tag}}"
docker run --name test-event-driver -d -p 22:22 -p 5001:5001 -p 3306:3306 \
-p 5432:5432 -p 28017:27017 -p 25:25 -p 5000:5000 -p 3001:3000 -p 6001:6001 -p 8001:8000 --privileged --pid=host --ipc=host --volume /:/host -v ~/git-server/keys:/git-server/keys \
-v ~/git-server/repos:/git-server/repos appsmith/test-event-driver:${{inputs.ted_tag}}
-v ~/git-server/repos:/git-server/repos "appsmith/test-event-driver:${ted_tag:-latest}"
docker run --name cloud-services -d -p 8000:80 -p 8090:8090 \
--privileged --pid=host --ipc=host --add-host=host.docker.internal:host-gateway\
-e APPSMITH_CLOUD_SERVICES_MONGODB_URI=mongodb://host.docker.internal:27017 \

View File

@ -15,6 +15,9 @@ import createSagaMiddleware from "redux-saga";
import store, { testStore } from "store";
import { sagasToRunForTests } from "./sagas";
import { all, call, spawn } from "redux-saga/effects";
import type { FeatureFlags } from "@appsmith/entities/FeatureFlag";
import { fetchFeatureFlagsSuccess } from "../src/actions/userActions";
import { DEFAULT_FEATURE_FLAG_VALUE } from "@appsmith/entities/FeatureFlag";
const testSagaMiddleware = createSagaMiddleware();
@ -44,13 +47,22 @@ const customRender = (
url?: string;
initialState?: Partial<AppState>;
sagasToRun?: typeof sagasToRunForTests;
featureFlags?: Partial<FeatureFlags>;
},
options?: Omit<RenderOptions, "queries">,
) => {
let reduxStore = store;
window.history.pushState({}, "Appsmith", state?.url || "/");
if (state && state.initialState) {
if (state && (state.initialState || state.featureFlags)) {
reduxStore = testStore(state.initialState || {});
if (state.featureFlags) {
reduxStore.dispatch(
fetchFeatureFlagsSuccess({
...DEFAULT_FEATURE_FLAG_VALUE,
...state.featureFlags,
}),
);
}
}
if (state && state.sagasToRun) {
reduxStore = testStoreWithTestMiddleWare(reduxStore.getState());

View File

@ -81,6 +81,9 @@ public class FeatureFlaggedMethodInvokerAspect {
Method superMethod = targetSuperClass.getMethod(method.getName(), method.getParameterTypes());
return superMethod.invoke(service, joinPoint.getArgs());
} catch (Throwable e) {
if (e instanceof AppsmithException) {
throw (AppsmithException) e;
}
String errorMessage = "Exception while invoking super class method";
AppsmithException exception = getInvalidAnnotationUsageException(method, errorMessage);
log.error(exception.getMessage(), e);

View File

@ -1,6 +1,8 @@
package com.appsmith.server.aspect;
import com.appsmith.server.aspect.component.TestComponent;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.featureflags.CachedFeatures;
import com.appsmith.server.featureflags.FeatureFlagEnum;
import com.appsmith.server.services.FeatureFlagService;
@ -19,6 +21,7 @@ import reactor.test.StepVerifier;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
@SpringBootTest
@ -120,4 +123,30 @@ class FeatureFlaggedMethodInvokerAspectTest {
String result = testComponent.ceEeSyncMethod("arg_");
assertEquals("arg_ce_impl_method", result);
}
@Test
void ceEeThrowAppsmithException_eeImplTest() {
CachedFeatures cachedFeatures = new CachedFeatures();
cachedFeatures.setFeatures(Map.of(FeatureFlagEnum.TENANT_TEST_FEATURE.name(), Boolean.TRUE));
Mockito.when(featureFlagService.getCachedTenantFeatureFlags()).thenReturn(cachedFeatures);
assertThrows(
AppsmithException.class,
() -> testComponent.ceEeThrowAppsmithException("arg_"),
AppsmithError.GENERIC_BAD_REQUEST.getMessage("This is a test exception"));
}
@Test
void ceEeThrowNonAppsmithException_eeImplTest_throwExceptionFromAspect() {
CachedFeatures cachedFeatures = new CachedFeatures();
cachedFeatures.setFeatures(Map.of(FeatureFlagEnum.TENANT_TEST_FEATURE.name(), Boolean.TRUE));
Mockito.when(featureFlagService.getCachedTenantFeatureFlags()).thenReturn(cachedFeatures);
assertThrows(
AppsmithException.class,
() -> testComponent.ceEeThrowNonAppsmithException("arg_"),
AppsmithError.INVALID_METHOD_LEVEL_ANNOTATION_USAGE.getMessage(
"FeatureFlagged",
"TestComponentImpl",
"ceEeThrowNonAppsmithException",
"Exception while invoking super class method"));
}
}

View File

@ -2,6 +2,8 @@ package com.appsmith.server.aspect.component;
import com.appsmith.server.annotations.FeatureFlagged;
import com.appsmith.server.aspect.component.ce_compatible.TestComponentCECompatibleImpl;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.featureflags.FeatureFlagEnum;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
@ -41,4 +43,16 @@ public class TestComponentImpl extends TestComponentCECompatibleImpl implements
public String ceEeSyncMethod(String arg) {
return arg + "ee_impl_method";
}
@Override
@FeatureFlagged(featureFlagName = FeatureFlagEnum.TENANT_TEST_FEATURE)
public void ceEeThrowAppsmithException(String arg) {
throw new AppsmithException(AppsmithError.GENERIC_BAD_REQUEST, "This is a test exception");
}
@Override
@FeatureFlagged(featureFlagName = FeatureFlagEnum.TENANT_TEST_FEATURE)
public void ceEeThrowNonAppsmithException(String arg) {
throw new RuntimeException("This is a test exception");
}
}

View File

@ -14,4 +14,8 @@ public interface TestComponentCE {
Flux<String> ceEeDiffMethodReturnsFlux();
String ceEeSyncMethod(String arg);
void ceEeThrowAppsmithException(String arg);
void ceEeThrowNonAppsmithException(String arg);
}

View File

@ -30,4 +30,10 @@ public class TestComponentCEImpl implements TestComponentCE {
public String ceEeSyncMethod(String arg) {
return arg + "ce_impl_method";
}
@Override
public void ceEeThrowAppsmithException(String arg) {}
@Override
public void ceEeThrowNonAppsmithException(String arg) {}
}