Skip to content

Commit b5fe0f6

Browse files
committed
Fix next review issues.
Remove tests `test_datadir_actions` that is part of `test_container_upgrade.py`. So removed. For testing settings new_password and new_user only one function is used. Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
1 parent ed331a2 commit b5fe0f6

File tree

6 files changed

+21
-75
lines changed

6 files changed

+21
-75
lines changed

test/test_container_general.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -186,39 +186,3 @@ def database_test(self, cip, username, password):
186186
database=f"db {VARS.SSL_OPTION}",
187187
sql_cmd="DROP TABLE tbl;",
188188
)
189-
190-
@pytest.mark.parametrize(
191-
"action",
192-
[
193-
"",
194-
"analyze",
195-
"optimize",
196-
],
197-
)
198-
def test_datadir_actions(self, action):
199-
"""
200-
Test if the datadir works properly with the different actions.
201-
Steps are:
202-
1. Create a container with the given arguments
203-
2. Check if the container is created successfully
204-
3. Check if the database connection works
205-
"""
206-
mysql_user = "user"
207-
mysql_password = "foo"
208-
mysql_database = "db"
209-
cid_test = f"test_upgrade_{action}"
210-
assert self.db_image.create_container(
211-
cid_file_name=cid_test,
212-
container_args=[
213-
f"-e MYSQL_USER={mysql_user}",
214-
f"-e MYSQL_PASSWORD={mysql_password}",
215-
f"-e MYSQL_DATABASE={mysql_database}",
216-
f"-v {self.datadir}/data:/var/lib/mysql/data:Z",
217-
],
218-
)
219-
cip, cid = self.db_image.get_cip_cid(cid_file_name=cid_test)
220-
assert cip, cid
221-
assert self.db_image.test_db_connection(
222-
container_ip=cip, username=mysql_user, password=mysql_password
223-
)
224-
PodmanCLIWrapper.call_podman_command(cmd=f"stop {cid}")

test/test_container_password.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,26 @@ def teardown_method(self):
4242
self.pwd_change.cleanup()
4343

4444
@pytest.mark.parametrize(
45-
"username, password, pwd_change",
45+
"username, password, pwd_change, user_change, test_dir",
4646
[
47-
("user", "foo", False),
48-
("user", "bar", True),
47+
("user", "foo", False, False, pwd_dir_change),
48+
("user", "bar", True, False, pwd_dir_change),
49+
("user", "foo", False, False, user_dir_change),
50+
("user2", "bar", False, True, user_dir_change),
4951
],
5052
)
51-
def test_password_change(self, username, password, pwd_change):
53+
def test_password_and_user_change(
54+
self, username, password, pwd_change, user_change, test_dir
55+
):
5256
"""
5357
Test password change.
5458
"""
5559

5660
self.password_change_test(
5761
username=username,
5862
password=password,
59-
pwd_dir=pwd_dir_change,
63+
pwd_dir=test_dir,
6064
pwd_change=pwd_change,
61-
)
62-
63-
@pytest.mark.parametrize(
64-
"username, password, user_change",
65-
[
66-
("user", "foo", False),
67-
("user2", "bar", True),
68-
],
69-
)
70-
def test_password_change_new_user_test(self, username, password, user_change):
71-
"""
72-
Test user change.
73-
"""
74-
self.password_change_test(
75-
username=username,
76-
password=password,
77-
pwd_dir=user_dir_change,
7865
user_change=user_change,
7966
)
8067

@@ -92,9 +79,11 @@ def password_change_test(
9279
1. Create a container with the given arguments
9380
2. Check if the container is created successfully
9481
3. Check if the database connection works
95-
4. Check if the userchange, then user2 does exist in the database
96-
5. Check if the password works
97-
6. Check if the password does not work
82+
4. If user_change is True, then 'user' and 'foo' are used for testing connection
83+
4. Check if the userchange, then user2 does exist in the database logs
84+
5. Check if the userchange, then sql command should work with the 'user' and 'bar' should
85+
not work and should return an error message
86+
6. If pwd_change is True, then 'user' and 'pwdfoo' should not work and should return an error message
9887
"""
9988
cid_file_name = f"test_{username}_{password}_{user_change}"
10089

test/test_container_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_cip_cid(self, cid_file_name):
3838

3939
def test_plugin_installation(self):
4040
"""
41-
Test plugin installation.
41+
Test installs a plugin that stores error messages in a log file and then checks that the plugin works correctly
4242
"""
4343
cid_file_name = "plugin_install"
4444
container_args = [

test/test_container_replication.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def test_replication(self):
7474
username="root",
7575
password="root",
7676
)
77-
slave_found = False
7877
for _ in range(3):
7978
result = self.db_wrapper_api.run_sql_command(
8079
container_ip=master_cip,
@@ -85,14 +84,11 @@ def test_replication(self):
8584
sql_cmd="SHOW SLAVE HOSTS;",
8685
podman_run_command="exec",
8786
)
88-
if not result:
89-
sleep(3)
90-
continue
9187
if slave_cip in result:
92-
slave_found = True
9388
break
9489
sleep(3)
95-
assert slave_found
90+
else:
91+
assert False, "Slave IP not found!"
9692
assert self.replication_db.test_db_connection(
9793
container_ip=slave_cip,
9894
username="root",
@@ -140,11 +136,6 @@ def test_replication(self):
140136
container_id=VARS.IMAGE_NAME,
141137
sql_cmd="select * from t1;",
142138
)
143-
# sql_cmd = "select * from t1;"
144-
# mysql_cmd = f'mysql -uroot <<< "{sql_cmd}"'
145-
# table_output = PodmanCLIWrapper.call_podman_command(
146-
# cmd=f"exec {slave_cid} bash -c '{mysql_cmd}'",
147-
# )
148139
assert re.search(r"^a\n^24", table_output, re.MULTILINE), (
149140
f"Replica {slave_cip} did not get value from MASTER {master_cip}"
150141
)

test/test_container_ssl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def teardown_method(self):
3030

3131
def test_ssl(self):
3232
"""
33-
Test SSL.
33+
Test verify that ssl connections works properly.
34+
The SSL certificates are self-signed and used for testing.
35+
The tests verifies that Ssl_cipher status is set to a valid value.
3436
"""
3537
ssl_dir = tempfile.mkdtemp(prefix="/tmp/mysql-ssl_data")
3638
username = "ssl_test_user"

test/test_container_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_upgrade_test(self, action):
103103
mysql_user=mysql_user, mysql_password=mysql_password, action="upgrade-auto"
104104
)
105105
assert not re.search("Running mysql_upgrade", output), (
106-
"mysql_upgrade did not run"
106+
"Unexpected mysql_upgrade found"
107107
)
108108
output = self.upgrade_db(
109109
mysql_user=mysql_user, mysql_password=mysql_password, action="upgrade-auto"

0 commit comments

Comments
 (0)