Skip to content

Commit 9f52225

Browse files
Raise error when role name > 32 chars
1 parent 6655767 commit 9f52225

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

docs/reference/software-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ juju run mysql-test-app/leader get-inserted-data
4141
# Start "continuous write" test:
4242
juju run mysql-test-app/leader start-continuous-writes
4343
export password=$(juju run mysql-k8s/leader get-password username=root | yq '.. | select(. | has("password")).password')
44-
watch -n1 -x juju ssh --container mysql mysql-k8s/leader "mysql -h 127.0.0.1 -uroot -p${password} -e \"select count(*) from continuous_writes_database.data\""
44+
watch -n1 -x juju ssh --container mysql mysql-k8s/leader "mysql -h 127.0.0.1 -uroot -p${password} -e \"select count(*) from continuous_writes.data\""
4545

4646
# Watch the counter is growing!
4747
```
4848
Expected results:
4949

50-
* mysql-test-app continuously inserts records in database `continuous_writes_database` table `data`.
50+
* mysql-test-app continuously inserts records in database `continuous_writes` table `data`.
5151
* the counters (amount of records in table) are growing on all cluster members
5252

5353
Hints:

lib/charms/mysql/v0/mysql.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,12 +1510,9 @@ def create_database(self, database: str) -> None:
15101510
"""Create an application database."""
15111511
role_name = f"charmed_dba_{database}"
15121512

1513-
if len(database) >= ROLE_MAX_LENGTH:
1514-
logger.error(f"Failed to create application database {database}")
1515-
raise MySQLCreateApplicationDatabaseError("Name longer than 32 characters")
15161513
if len(role_name) >= ROLE_MAX_LENGTH:
1517-
logger.warning(f"Pruning application database role name {role_name}")
1518-
role_name = role_name[:ROLE_MAX_LENGTH]
1514+
logger.error(f"Failed to create application database {database}")
1515+
raise MySQLCreateApplicationDatabaseError("Role name longer than 32 characters")
15191516

15201517
create_database_commands = (
15211518
"shell.connect_to_primary()",

tests/integration/high_availability/high_availability_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
)
3333

3434
# Copied these values from high_availability.application_charm.src.charm
35-
DATABASE_NAME = "continuous_writes_database"
35+
DATABASE_NAME = "continuous_writes"
3636
TABLE_NAME = "data"
3737

3838
CLUSTER_NAME = "test_cluster"

tests/integration/relations/test_mysql_root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def test_build_and_deploy(ops_test: OpsTest, charm):
2929
config = {
3030
"profile": "testing",
3131
"mysql-root-interface-user": "test-user",
32-
"mysql-root-interface-database": "continuous_writes_database",
32+
"mysql-root-interface-database": "continuous_writes",
3333
}
3434
resources = {
3535
"mysql-image": DB_METADATA["resources"]["mysql-image"]["upstream-source"],

0 commit comments

Comments
 (0)