-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
chore: setup for server test changes and fixing few #33847
Conversation
@@ -56,6 +57,8 @@ public enum AuthenticationStatus { | |||
@JsonView(Views.Internal.class) | |||
AuthenticationResponse authenticationResponse; | |||
|
|||
@JsonView(Views.Public.class) | |||
@Transient | |||
public Mono<Boolean> hasExpired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
persistence fails so making is transient
@@ -141,14 +139,5 @@ public void updateForBulkWriteOperation() { | |||
this.setUpdatedAt(Instant.now()); | |||
} | |||
|
|||
@PrePersist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed anymore as we are assigning id now in save method itself
@@ -32,6 +32,7 @@ public enum TableType { | |||
|
|||
@Data | |||
@AllArgsConstructor | |||
@NoArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed as serde was failing in few tests
@@ -256,7 +256,7 @@ private Mono<Application> createSuffixedApplication(Application application, Str | |||
return super.create(application).onErrorResume(DataIntegrityViolationException.class, error -> { | |||
if (error.getMessage() != null | |||
// Catch only if error message contains workspace_app_deleted_git_application_metadata mongo error | |||
&& error.getMessage().contains("workspace_app_deleted_git_application_metadata")) { | |||
&& (error.getMessage().contains("u_workspace_app"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index name has changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the nomenclature same for the indexes? That way we don't have to look into different branches if we face some issues in future.
Set<Policy> policies = mapObject(policiesJson, new TypeReference<Set<Policy>>() {}); | ||
TenantConfiguration tenantConfiguration = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated after found yesterday that tenantconfiguration was setting up null if not provided here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this in the docs as well seems to be something which can be missed by other devs.
@@ -26,15 +27,16 @@ private void addAnonymousUser() throws JsonProcessingException { | |||
return; | |||
} | |||
String insertUserQuery = | |||
"INSERT INTO \"user\" (id, email, name, current_workspace_id, workspace_ids, is_anonymous, tenant_id, is_system_generated, created_at, updated_at) VALUES (gen_random_uuid(), ?, ?, ?, cast(? as jsonb), ?, ?, true, now() ,now())"; | |||
"INSERT INTO \"user\" (id, email, name, current_workspace_id, workspace_ids, is_anonymous, tenant_id, source, is_system_generated, created_at, updated_at) VALUES (gen_random_uuid(), ?, ?, ?, cast(? as jsonb), ?, ?, ?, true, now() ,now())"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
login source was missing earlier
public Mono<T> save(T entity) { | ||
return Mono.fromSupplier(() -> repository.save(entity)).subscribeOn(Schedulers.boundedElastic()); | ||
return Mono.fromSupplier(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updates save method so that we can deal with save failures ourselves
if (error.getMessage() != null | ||
&& error.getMessage().contains("workspace_datasource_deleted_compound_index") | ||
&& error.getMessage().contains("u_workspace_datasource") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index name changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -6,6 +6,10 @@ create unique index if not exists u_email on password_reset_token(email); | |||
create unique index if not exists plugin_name_package_name_version_index on plugin(plugin_name, package_name, version); | |||
create unique index if not exists u_user_id on user_data(user_id); | |||
create unique index if not exists u_workspace_datasource_deleted on datasource(workspace_id, name, deleted_at); | |||
CREATE UNIQUE INDEX if not exists u_workspace_datasource ON datasource (workspace_id, name) WHERE deleted_at IS NULL; | |||
create unique index if not exists u_workspace_app_deleted on application(workspace_id, name, deleted_at) where git_application_metadata is null; | |||
create unique index if not exists u_workspace_app on application(workspace_id, name) where deleted_at is null and git_application_metadata is null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new index addition based on the fact that null values aren't treated same in postgres and we need different indexes if a value part of index is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share more details on this, just a ref should be enough?
|
||
@Profile("test") | ||
@Configuration | ||
public class TestDatabaseConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config specific to tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the javadoc comment to define the purpose, and also provide the reason why this is needed in tests against the production environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, added few minor comment for clarification.
@@ -256,7 +256,7 @@ private Mono<Application> createSuffixedApplication(Application application, Str | |||
return super.create(application).onErrorResume(DataIntegrityViolationException.class, error -> { | |||
if (error.getMessage() != null | |||
// Catch only if error message contains workspace_app_deleted_git_application_metadata mongo error | |||
&& error.getMessage().contains("workspace_app_deleted_git_application_metadata")) { | |||
&& (error.getMessage().contains("u_workspace_app"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the nomenclature same for the indexes? That way we don't have to look into different branches if we face some issues in future.
@@ -28,7 +30,7 @@ public ResolvedMigration getResolvedMigration(Configuration config, StatementInt | |||
public final void migrate(Context context) throws Exception { | |||
JdbcTemplate jdbcTemplate = | |||
new JdbcTemplate(new SingleConnectionDataSource(context.getConnection(), true), false); | |||
|
|||
log.info("Running migration: {}", this.getClass().getSimpleName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the expected logs here? Does logs from flyway not sufficient for us.
Set<Policy> policies = mapObject(policiesJson, new TypeReference<Set<Policy>>() {}); | ||
TenantConfiguration tenantConfiguration = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this in the docs as well seems to be something which can be missed by other devs.
if (error.getMessage() != null | ||
&& error.getMessage().contains("workspace_datasource_deleted_compound_index") | ||
&& error.getMessage().contains("u_workspace_datasource") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
...ver/appsmith-server/src/main/java/com/appsmith/server/services/ce/MockDataServiceCEImpl.java
Outdated
Show resolved
Hide resolved
@@ -159,6 +159,7 @@ public void testGetMockDataSets() { | |||
|
|||
@Test | |||
@WithUserDetails(value = "api_user") | |||
@Order(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific need for this ordering? We ideally want each test to be self sufficient.
@@ -48,7 +48,7 @@ | |||
|
|||
import static org.assertj.core.api.Assertions.assertThat; | |||
|
|||
@ExtendWith(SpringExtension.class) | |||
@ExtendWith(AfterAllCleanUpExtension.class) | |||
@SpringBootTest | |||
public class AuthenticationServiceTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we require @DirtiesContext
here?
@@ -49,11 +49,10 @@ | |||
import static org.mockito.Mockito.any; | |||
import static org.mockito.Mockito.doReturn; | |||
|
|||
@ExtendWith(SpringExtension.class) | |||
@ExtendWith(AfterAllCleanUpExtension.class) | |||
@SpringBootTest | |||
@Slf4j | |||
public class DatasourceStructureSolutionTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here @DirtiesContext
is missing.
@@ -61,10 +61,9 @@ | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
|
|||
@Slf4j | |||
@ExtendWith(SpringExtension.class) | |||
@ExtendWith(AfterAllCleanUpExtension.class) | |||
@SpringBootTest | |||
public class PartialExportServiceTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DirtiesContext
is missing.
@@ -91,7 +91,7 @@ | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.ArgumentMatchers.any; | |||
|
|||
@ExtendWith(SpringExtension.class) | |||
@ExtendWith(AfterAllCleanUpExtension.class) | |||
@SpringBootTest | |||
@Slf4j | |||
public class ActionExecutionSolutionCETest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DirtiesContext
is missing
Failed server tests
|
1 similar comment
Failed server tests
|
@abhvsn with index, names are very similar just that we have shorten as required and in case of application on |
Failed server tests
|
Failed server tests
|
Description
Tip
Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).
Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.
Fixes #
Issue Number
or
Fixes
Issue URL
Warning
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags=""
🔍 Cypress test results
Caution
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?