-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(sql-setup): system-update replacement for mysql/postgres setup #15044
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
base: master
Are you sure you want to change the base?
Conversation
mockSetupArgs.createUser = true; | ||
mockSetupArgs.iamAuthEnabled = false; | ||
mockSetupArgs.createUserUsername = "testuser"; | ||
mockSetupArgs.createUserPassword = "testpass"; |
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.
Exposed secret in datahub-upgrade/src/test/java/com/linkedin/datahub/upgrade/sqlsetup/CreateUsersStepTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security
args.cdcUser = "custom_cdc"; | ||
args.cdcPassword = "custom_password"; | ||
args.createUserUsername = "testuser"; | ||
args.createUserPassword = "testpass"; |
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.
Exposed secret in datahub-upgrade/src/test/java/com/linkedin/datahub/upgrade/sqlsetup/SqlSetupArgsTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security
@Test | ||
public void testGetCreateTraditionalUserSqlMysql() throws Exception { | ||
mockSetupArgs.createUserUsername = "mysqluser"; | ||
mockSetupArgs.createUserPassword = "mysqlpass"; |
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.
Exposed secret in datahub-upgrade/src/test/java/com/linkedin/datahub/upgrade/sqlsetup/CreateUsersStepTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security
args.iamAuthEnabled = false; | ||
args.createUser = true; | ||
args.createUserUsername = null; // Missing createUserUsername | ||
args.createUserPassword = "testpass"; |
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.
Exposed secret in datahub-upgrade/src/test/java/com/linkedin/datahub/upgrade/sqlsetup/config/SqlSetupConfigTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security
f1eb4f4
to
878e0c0
Compare
✅ Meticulous spotted 0 visual differences across 1001 screens tested: view results. Meticulous evaluated ~8 hours of user flows against your PR. Expected differences? Click here. Last updated for commit fb48432. This comment will update as new commits are pushed. |
* better support for IAM
878e0c0
to
fb48432
Compare
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.
I've gotten through most of it. Mostly stylistic feedback so far.
|
||
import lombok.Data; | ||
|
||
@Data |
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.
Prefer immutable types. Replace with the following?
@Value
@Builder
@ToString(exclude = "errorMessage")
public int tablesCreated = 0; | ||
public int usersCreated = 0; | ||
public boolean cdcUserCreated = false; | ||
public long executionTimeMs = 0; | ||
public String errorMessage; |
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.
These should not be public if we've got @Data
.
public String errorMessage; | ||
|
||
@Override | ||
public String toString() { |
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.
Why exclude errorMessage
? In any case, lombok can do that for us.
|
||
import org.testng.annotations.Test; | ||
|
||
public class SqlSetupResultTest { |
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.
This test file should not exist at all. This is why we use Lombok.
|
||
import lombok.Data; | ||
|
||
@Data |
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.
We should prefer @Value
. The fields should not be public.
} | ||
|
||
void createDatabaseIfNotExists(String databaseName, DatabaseType dbType) throws SQLException { | ||
if (DatabaseType.POSTGRES.equals(dbType)) { |
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.
I see these conditionals at a few places. How about extracting an interface and having separate impls for Postgres vs Mysql?
import java.util.List; | ||
import javax.annotation.Nullable; | ||
|
||
public class SqlSetup implements Upgrade { |
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.
Add javadoc.
import org.testng.annotations.Test; | ||
|
||
@TestPropertySource(properties = {"entityService.impl=ebean"}) | ||
public class SqlSetupUpgradeConfigTest { |
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.
IMO, this test is pure maintenance burden and should be deleted. It'll never catch real bugs; all it does is give false confidence about test coverage :)
import org.testng.annotations.Test; | ||
|
||
/** Unit tests for DatabaseType enum. */ | ||
public class DatabaseTypeTest { |
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.
Claude got really intense with unit testing this class. I think this is a serious problem. I asked claude to write down my arguments against over-testing here:
PTAL and we can discuss.
|
||
import org.testng.annotations.Test; | ||
|
||
public class SqlSetupArgsTest { |
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.
Another test class that we should drop.
SQL Setup Upgrade System
Overview
This PR introduces a comprehensive SQL setup upgrade system for DataHub that enables automated database initialization, table creation, and user management for both MySQL and PostgreSQL databases. The system supports both traditional authentication and IAM-based authentication, making it suitable for various deployment scenarios.
Key Features
🗄️ Database Support
🔧 Core Functionality
metadata_aspect_v2
table with proper schemaEnvironment Variables
Core Configuration
CREATE_TABLES
true
CREATE_DB
true
CREATE_USER
false
CDC_MCL_PROCESSING_ENABLED
false
CDC_USER
datahub_cdc
CDC_PASSWORD
datahub_cdc
IAM_ROLE
Database Connection
The system automatically extracts connection details from Spring Ebean configuration:
ebean.username
andebean.password
ebean.useIamAuth
settingUsage Examples
Basic Table Creation
With User Creation
With CDC Support