-
Notifications
You must be signed in to change notification settings - Fork 4.5k
test: Enable server tests for the PRs with base PG branch #33429
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
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
03777b2
feat: Enable server tests on PRs raised on PG branch
abhvsn 7256d66
feat: Add postgresql docker image before running the tests
abhvsn 72c8718
chore: Minor refactor
abhvsn 15ec4c3
chore: Move the transform script trigger to build.sh
abhvsn a7d9ccd
Merge branch 'release' of github.com:appsmithorg/appsmith into feat/e…
abhvsn b5c0601
chore: Update the DB URI env variable
abhvsn 4ba5004
chore: Add verbose comment for postgres URI check
abhvsn 0c4f065
fix: Updated name for URI in migration
abhvsn 35800ce
refactor: Remove application-production.properties to avoid the confu…
abhvsn 99c6e5c
chore: Run transform script to add the cake classes
abhvsn 68cb893
Merge branch 'release' of github.com:appsmithorg/appsmith into feat/e…
abhvsn 95c6c05
Merge branch 'feat/enable-server-tests-for-pg' of github.com:appsmith…
abhvsn acd841b
feat: Add fallback for DB URI in entrypoint.sh
abhvsn 25bbced
chore: Remove envs while building the server
abhvsn 17a659f
fix: DB URI name
abhvsn c84744b
chore: Update the DB URL variable
abhvsn ea58c43
refactor: Add DB url config in entrypoint.sh
abhvsn e34e211
cleanup: Remove un-necessary migration to update db URL name
abhvsn 285cb37
chore: Remove fallback for DB URL
abhvsn bfc372c
feat: Add more context on DB url to initialise the DB from entrypoint.sh
abhvsn 4ce41e5
fix: Postgres container run command for running the tests
abhvsn fab1e9b
chore: Update the check to test for jdbc string at the start of the D…
abhvsn 30c7cba
chore: Replace the DB name in few other files
abhvsn 146a224
fix: DB URL name in readme
abhvsn 1ba2d2e
chore: Add stricter checks for DB URL and don't provide fallback for …
abhvsn 8ec2ebc
chore: Add Postgres envs for username and password
abhvsn 2d5a4ab
feat: Handle bean initialisation for DB configs
abhvsn 382b9ec
chore: Update DB URL name in env and readme files
abhvsn d0a0968
Merge branch 'feat/enable-server-tests-for-pg' of github.com:appsmith…
abhvsn 3373b5d
revert: Nomenclature change for deploy-preview script
abhvsn 0a1199f
chore: Add `ORing` in config map to support backward compatibility
abhvsn f00bdcf
feat: Add fallback for APPSMITH_DB_URL in run_with_env script
abhvsn 87fe4ca
feat: Add fallback for APPSMITH_DB_URL in index.js within deploy dire…
abhvsn 1562e3e
revert: EnvManager to use existing APPSMITH_MONGODB_URI, as this will…
abhvsn 4e837fc
Merge branch 'chore/few-more-updates' of github.com:appsmithorg/appsm…
abhvsn ed131f3
Merge branch 'feat/enable-server-tests-for-pg' into chore/few-more-up…
abhvsn 0e32b6e
chore: Update DB connection url in CI
abhvsn 22716b4
chore: Keep the fallback DB connection url for local dev till this is…
abhvsn 8ef7d20
Merge branch 'release' of github.com:appsmithorg/appsmith into feat/e…
abhvsn 21a8284
Merge branch 'feat/enable-server-tests-for-pg' into chore/few-more-up…
abhvsn 5357654
chore: Remove the requirement for jdbc prefix for postgres connection…
abhvsn fcbc861
Merge branch 'feat/enable-server-tests-for-pg' into chore/few-more-up…
abhvsn cfe5a1d
test: Update tests
abhvsn 2fc22dd
Merge branch 'feat/enable-server-tests-for-pg' into chore/few-more-up…
abhvsn 047c56c
chore: Remove the step to append jdbc
abhvsn 7e3a79a
Merge branch 'release' of github.com:appsmithorg/appsmith into feat/e…
abhvsn 895173d
fix: Add profile check for DB config to configure embedded MongoDB fo…
abhvsn 3f61efa
chore: Migrate DB name from `APPSMITH_MONGODB_URI` to `APPSMITH_DB_URL`
abhvsn 7a8b8d0
Merge branch 'release' of github.com:appsmithorg/appsmith into feat/e…
abhvsn f1837b5
fix: Tests
abhvsn 020842c
Merge branch 'feat/enable-server-tests-for-pg' of github.com:appsmith…
abhvsn 6b0a942
Update deploy/docker/fs/opt/appsmith/utils/bin/backup.js
abhvsn 1fb63ec
chore: Remove prefix support for Postgres DB URL
abhvsn 762b425
Merge branch 'feat/enable-server-tests-for-pg' of github.com:appsmith…
abhvsn fb96715
revert: Helm changes
abhvsn 2687595
revert: Unwanted changes from entrypoint
abhvsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...rver/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonDBConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package com.appsmith.server.configurations; | ||
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | ||
| import org.springframework.boot.autoconfigure.mongo.MongoProperties; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import java.net.URI; | ||
| import java.net.URISyntaxException; | ||
|
|
||
| /** | ||
| * Class to configure beans based on DB url. This could have been implemented in {@link MongoConfig} or | ||
| * {@link DBConfig} but extracted to seperate class as we were facing cyclical dependency issue with the other approach | ||
| */ | ||
| @Configuration | ||
| @Slf4j | ||
| public class CommonDBConfig { | ||
|
|
||
| @Value("${appsmith.db.url}") | ||
| private String appsmithDbUrl; | ||
|
|
||
| static final String JDBC_PREFIX = "jdbc:"; | ||
|
|
||
| @Bean | ||
| @Primary | ||
| @Profile("!test") | ||
| public MongoProperties configureMongoDB() { | ||
| if (!appsmithDbUrl.startsWith("mongodb")) { | ||
| return null; | ||
| } | ||
| log.info("Found MongoDB uri configuring now"); | ||
| MongoProperties mongoProperties = new MongoProperties(); | ||
| mongoProperties.setUri(appsmithDbUrl); | ||
| return mongoProperties; | ||
| } | ||
|
|
||
| @Bean | ||
| @Primary | ||
| public DataSourceProperties configurePostgresDB() { | ||
| if (!appsmithDbUrl.contains("postgresql")) { | ||
| return null; | ||
| } | ||
| log.info("Found PostgreSQL uri configuring now"); | ||
| return extractJdbcProperties(appsmithDbUrl); | ||
| } | ||
|
|
||
| /** | ||
| * Method to extract Jdbc props from the given DB URL | ||
| * Expected DB URL: postgresql://{username}:{password}@localhost:{port}/{db_name} | ||
| */ | ||
| public DataSourceProperties extractJdbcProperties(String dbUrl) { | ||
| DataSourceProperties ds = new DataSourceProperties(); | ||
| try { | ||
| URI uri = new URI(dbUrl); | ||
| if (!StringUtils.hasLength(uri.getHost())) { | ||
| String errorString = String.format( | ||
| "Malformed DB URL! Expected format: postgresql://{username}:{password}@localhost:{port}/{db_name}, provided url is %s", | ||
| dbUrl); | ||
| throw new IllegalArgumentException(errorString); | ||
| } | ||
| String userInfo = uri.getUserInfo(); | ||
| if (StringUtils.hasLength(userInfo)) { | ||
| String[] userDetails = userInfo.split(":"); | ||
| ds.setUsername(userDetails[0]); | ||
| ds.setPassword(userDetails[1]); | ||
| } | ||
| // If the port is not mentioned default it to standard 5432 | ||
| int port = uri.getPort() == -1 ? 5432 : uri.getPort(); | ||
| String updatedUrl = | ||
| String.format("%s%s://%s:%s%s", JDBC_PREFIX, uri.getScheme(), uri.getHost(), port, uri.getPath()); | ||
| ds.setUrl(updatedUrl); | ||
| return ds; | ||
| } catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } |
2 changes: 0 additions & 2 deletions
2
app/server/appsmith-server/src/main/resources/application-production.properties
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../appsmith-server/src/test/java/com/appsmith/server/configurations/CommonDBConfigTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.appsmith.server.configurations; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| class CommonDBConfigTest { | ||
|
|
||
| @Test | ||
| public void testExtractAndSaveJdbcParams_validDbUrlWithUsernameAndPassword() { | ||
| CommonDBConfig commonDBConfig = new CommonDBConfig(); | ||
| String dbUrl = "postgresql://postgres:password@localhost/postgres"; | ||
| DataSourceProperties ds = commonDBConfig.extractJdbcProperties(dbUrl); | ||
| assertEquals("postgres", ds.getUsername()); | ||
| assertEquals("password", ds.getPassword()); | ||
| assertEquals("jdbc:postgresql://localhost:5432/postgres", ds.getUrl()); | ||
|
|
||
| String dbUrlWithPort = "postgresql://postgres:password@localhost:1234/postgres"; | ||
| ds = commonDBConfig.extractJdbcProperties(dbUrlWithPort); | ||
| assertEquals("postgres", ds.getUsername()); | ||
| assertEquals("password", ds.getPassword()); | ||
| assertEquals("jdbc:postgresql://localhost:1234/postgres", ds.getUrl()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExtractAndSaveJdbcParams_validDbUrlWithoutUsernameAndPassword() { | ||
| CommonDBConfig commonDBConfig = new CommonDBConfig(); | ||
| String dbUrl = "postgresql://localhost:5432/postgres"; | ||
| DataSourceProperties ds = commonDBConfig.extractJdbcProperties(dbUrl); | ||
| assertNull(ds.getUsername()); | ||
| assertNull(ds.getPassword()); | ||
| assertEquals("jdbc:postgresql://localhost:5432/postgres", ds.getUrl()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExtractAndSaveJdbcParams_invalidDbUrl() { | ||
| CommonDBConfig commonDBConfig = new CommonDBConfig(); | ||
| String dbUrl = "jdbc:postgresql://localhost/postgres"; | ||
| String errorString = String.format( | ||
| "Malformed DB URL! Expected format: postgresql://{username}:{password}@localhost:{port}/{db_name}, provided url is %s", | ||
| dbUrl); | ||
| assertThrows(IllegalArgumentException.class, () -> commonDBConfig.extractJdbcProperties(dbUrl), errorString); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.