Add tests for mysqlclient-utility container

- test_verify_readonly_rootfs

Change-Id: Icb1adc22e08c89bfceb3b8e58d92d3c1c020ac29
This commit is contained in:
PrateekDodda 2020-07-27 16:32:46 -05:00 committed by diwakar thyagaraj
parent 80c0a35be0
commit 85f1b6c0ff
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
# Copyright 2020 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re
import unittest
from kube_utility_container.tests.utility.base import TestBase
class TestMysqlclientUtilityContainer(TestBase):
@classmethod
def setUpClass(cls):
cls.deployment_name = 'mysqlclient-utility'
super(TestMysqlclientUtilityContainer, cls).setUpClass()
def test_verify_readonly_rootfs(self):
"""To verify mysqlclient-utility readonly rootfs configuration"""
failures = []
expected = "False"
mysqlclient_utility_pod = \
self.client._get_utility_container(self.deployment_name)
for container in mysqlclient_utility_pod.spec.containers:
if expected != \
str(container.security_context.read_only_root_filesystem):
failures.append(
f"container {container.name} is not having expected"
f" value {expected} set for read_only_root_filesystem"
f" in pod {mysqlclient_utility_pod.metadata.name}")
self.assertEqual(0, len(failures), failures)

View File

@ -49,6 +49,7 @@ function run_feature_tests() {
python -m unittest discover -s ${PLUGINS}/tests/utility/etcd -v
python -m unittest discover -s ${PLUGINS}/tests/utility/calico -v
python -m unittest discover -s ${PLUGINS}/tests/utility/ceph -v
python -m unittest discover -s ${PLUGINS}/tests/utility/mysqlclient -v
}
function run_unit_tests() {