From 32077268fa824ad6527f2026a6f9c37e7f4539e0 Mon Sep 17 00:00:00 2001 From: Canux CHENG Date: Tue, 26 Nov 2019 03:09:46 +0000 Subject: [PATCH] remove parameters --- tests/test_database_wrapper.py | 12 ++++++------ tests/test_docker.py | 26 +++++++++++++------------- tests/test_grafana_wrapper.py | 8 ++++---- tests/test_influxdb_wrapper.py | 3 --- tests/test_redis_wrapper.py | 2 +- tests/test_smtp_wrapper.py | 4 ++-- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/tests/test_database_wrapper.py b/tests/test_database_wrapper.py index ba556a9..4f6c317 100644 --- a/tests/test_database_wrapper.py +++ b/tests/test_database_wrapper.py @@ -6,8 +6,8 @@ class DatabaseTestCase(unittest.TestCase): def test_select_query(self): with BaseDB( - host='10.103.239.70', username='sandbox', - password='P@ssword', database='sandbox', port=1433 + host='127.0.0.1', username='username', + password='password', database='test', port=1433 ) as db: results, keys = db.select_query("select @@version") self.assertIsInstance(results, list, msg='results failed') @@ -45,10 +45,10 @@ def test_dml_query(self): host='127.0.0.1', username='username', password='password', database='test', port=1433 ) as db: - result = db.dml_query("delete from jobs where sample_sha256 = " - "'4ed869e5c11e23218d808f91b341f4e5fc28f729c2477f71cee956cf50dd3b16'") - result1 = db.dml_query("update samples set status = 'bad' where " - "sha256 = '4ed869e5c11e23218d808f91b341f4e5fc28f729c2477f71cee956cf50dd3b16'") + result = db.dml_query("delete from table where key = " + "'value'") + result1 = db.dml_query("update table set key = 'value' where " + "key = 'value'") if __name__ == '__main__': diff --git a/tests/test_docker.py b/tests/test_docker.py index ccb0153..ebdee6a 100644 --- a/tests/test_docker.py +++ b/tests/test_docker.py @@ -44,7 +44,7 @@ def test_swarm_init(self): node_id = None with BaseSwarm() as swarm: node_id = swarm.init( - advertise_addr="10.103.239.40", force_new_cluster=True + advertise_addr="127.0.0.1", force_new_cluster=True ) print(node_id) self.assertIsNotNone(node_id, "swarm init failed") @@ -52,8 +52,8 @@ def test_swarm_init(self): @unittest.skip("ignore") def test_swarm_join(self): with BaseParamiko( - hostname="10.103.239.40", username="canux", - password="S0nicwall" + hostname="127.0.0.1", username="usernme", + password="password" ) as ssh: output, error, rc = ssh.exec_command( "docker swarm join-token -q worker" @@ -62,18 +62,18 @@ def test_swarm_join(self): print(token) with BaseSwarm() as swarm: result = swarm.join( - remote_addrs=["10.103.239.40:2377"], - join_token=token, advertise_addr="10.103.239.40" + remote_addrs=["127.0.0.1:2377"], + join_token=token, advertise_addr="127.0.0.1" ) self.assertTrue(result, "swarm join failed.") @unittest.skip("ignore") def test_overlay(self): - name = "ol0" - subnet = "172.12.0.0/16" - iprange = "172.12.0.0/24" - gateway = "172.12.0.1" - opt_name = "ol0" + name = "docker1" + subnet = "172.19.0.0/16" + iprange = "172.19.0.0/24" + gateway = "172.19.0.1" + opt_name = "docker1" with BaseNetworks() as network: result = network.create_overlay_network( name=name, subnet=subnet, iprange=iprange, gateway=gateway, @@ -84,9 +84,9 @@ def test_overlay(self): @unittest.skip("ignore") def test_get_captureatp_version(self): - registry = "harbor.domain.com:4433" - project = "captureatp" - name = "sandboxav" + registry = "harbor.domain.com:443" + project = "app" + name = "test" repo = "{}/{}/{}".format(registry, project, name) with BaseImages() as image: images = image.list(repo, if_all=True) diff --git a/tests/test_grafana_wrapper.py b/tests/test_grafana_wrapper.py index ec5654d..b7193c6 100644 --- a/tests/test_grafana_wrapper.py +++ b/tests/test_grafana_wrapper.py @@ -6,16 +6,16 @@ class GrafanaTestCase(unittest.TestCase): @unittest.skip('ignore') def test_check_datasource_exist(self): - grafana = BaseGrafana("http://10.103.64.207:3000", "sandbox", + grafana = BaseGrafana("http://127.0.0.1:3000", "admin", "password") - result = grafana.check_data_source_exist_by_name("MAF") + result = grafana.check_data_source_exist_by_name("devops") self.assertEqual(True, result, msg="check datasource exist failed.") def test_check_datasource_exist(self): - grafana = BaseGrafana("http://10.103.64.207:3000", + grafana = BaseGrafana("http://127.0.0.1:3000", 'eyJrIjoiSU84dnphRGlOUTlaeGNCdTQ3clJlZjBxZG9IUFQ3cGoiLCJuIjoidGVzdCIsImlkIjoxfQ==' ) - result = grafana.check_data_source_exist_by_name("MAF") + result = grafana.check_data_source_exist_by_name("devops") self.assertEqual(True, result, msg="check datasource exist failed.") diff --git a/tests/test_influxdb_wrapper.py b/tests/test_influxdb_wrapper.py index c44cb38..c1464e5 100644 --- a/tests/test_influxdb_wrapper.py +++ b/tests/test_influxdb_wrapper.py @@ -30,9 +30,6 @@ def test_query(self): """ result = BaseInfluxdb().query("devops", ifql) self.assertIsNotNone(result, 'select failed.') - """ - {'results': [{'statement_id': 0, 'series': [{'name': 'cpu', 'tags': {'host': 'AT-MySQL'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.03125586093945287], ['2019-11-19T09:40:00Z', 0.03958997499701411], ['2019-11-19T09:41:00Z', 0.04375117218303615], ['2019-11-19T09:42:00Z', 0.04583723990482724], ['2019-11-19T09:43:00Z', 0.04167330867234398], ['2019-11-19T09:44:00Z', 0.04688125038921953]]}, {'name': 'cpu', 'tags': {'host': 'AT-Rabbitmq-Haproxy'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.2501250627643259], ['2019-11-19T09:40:00Z', 0.2669670173403347], ['2019-11-19T09:41:00Z', 0.35020860447122004], ['2019-11-19T09:42:00Z', 0.300250225104719], ['2019-11-19T09:43:00Z', 0.31704212966837986], ['2019-11-19T09:44:00Z', 0.37507522549957173]]}, {'name': 'cpu', 'tags': {'host': 'AT-Rabbitmq01'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.4509018040227346], ['2019-11-19T09:40:00Z', 0.48381715054661356], ['2019-11-19T09:41:00Z', 0.583450116553351], ['2019-11-19T09:42:00Z', 0.5669502336797478], ['2019-11-19T09:43:00Z', 0.5671756715035485], ['2019-11-19T09:44:00Z', 0.47571357079544896]]}, {'name': 'cpu', 'tags': {'host': 'AT-Rabbitmq02'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.15022533814712347], ['2019-11-19T09:40:00Z', 0.33358354216329644], ['2019-11-19T09:41:00Z', 0.38348345841518494], ['2019-11-19T09:42:00Z', 0.36691691687042294], ['2019-11-19T09:43:00Z', 0.4001001000847708], ['2019-11-19T09:44:00Z', 0.40028773124370787]]}, {'name': 'cpu', 'tags': {'host': 'AT-Redis'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.05003752819244767], ['2019-11-19T09:40:00Z', 0.141675032254156], ['2019-11-19T09:41:00Z', 0.11671252617077243], ['2019-11-19T09:42:00Z', 0.14165005411926757], ['2019-11-19T09:43:00Z', 0.10837710878057294], ['2019-11-19T09:44:00Z', 0.16255001763602195]]}, {'name': 'cpu', 'tags': {'host': 'backup-server'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 1.587996248276184], ['2019-11-19T09:40:00Z', 1.1777606965329852], ['2019-11-19T09:41:00Z', 1.2629336351638472], ['2019-11-19T09:42:00Z', 1.240201263942751], ['2019-11-19T09:43:00Z', 1.127428122710569], ['2019-11-19T09:44:00Z', 1.22249467921921]]}, {'name': 'cpu', 'tags': {'host': 'gitlab'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 3.8281103402784424], ['2019-11-19T09:40:00Z', 3.311290865158], ['2019-11-19T09:41:00Z', 3.5475162263316946], ['2019-11-19T09:42:00Z', 3.353584195154781], ['2019-11-19T09:43:00Z', 3.336089292237105], ['2019-11-19T09:44:00Z', 2.692893340444357]]}, {'name': 'cpu', 'tags': {'host': 'jenkins'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.1626524865668415], ['2019-11-19T09:40:00Z', 0.11885217371116141], ['2019-11-19T09:41:00Z', 0.1063542732930074], ['2019-11-19T09:42:00Z', 0.1125980023593911], ['2019-11-19T09:43:00Z', 0.10843003414701968], ['2019-11-19T09:44:00Z', 0.07194264214393797]]}, {'name': 'cpu', 'tags': {'host': 'repo-ubuntu16'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 16.326416465400754], ['2019-11-19T09:40:00Z', 16.987985865078528], ['2019-11-19T09:41:00Z', 16.027362414904218], ['2019-11-19T09:42:00Z', 15.930524600712772], ['2019-11-19T09:43:00Z', 16.177572516879493], ['2019-11-19T09:44:00Z', 18.010139417063854]]}, {'name': 'cpu', 'tags': {'host': 'research'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 30.47511595803742], ['2019-11-19T09:40:00Z', 36.42952133947917], ['2019-11-19T09:41:00Z', 24.29001018455432], ['2019-11-19T09:42:00Z', 3.689162605377419], ['2019-11-19T09:43:00Z', 9.95440521676737], ['2019-11-19T09:44:00Z', 12.720892342859742]]}, {'name': 'cpu', 'tags': {'host': 'samples'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 1.1638092845018377], ['2019-11-19T09:40:00Z', 1.5474272887059897], ['2019-11-19T09:41:00Z', 1.5473625546416798], ['2019-11-19T09:42:00Z', 1.3978749994601003], ['2019-11-19T09:43:00Z', 1.2135650349546694], ['2019-11-19T09:44:00Z', 1.4077570875834908]]}, {'name': 'cpu', 'tags': {'host': 'soniclinux-repo'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 0.5005004986481225], ['2019-11-19T09:40:00Z', 0.4839175766902031], ['2019-11-19T09:41:00Z', 0.8690839841601843], ['2019-11-19T09:42:00Z', 0.6685232929676204], ['2019-11-19T09:43:00Z', 1.0696469107433728], ['2019-11-19T09:44:00Z', 0.5005004986481225]]}, {'name': 'cpu', 'tags': {'host': 'workstation'}, 'columns': ['time', 'idle'], 'values': [['2019-11-19T09:39:00Z', 2.6376720900224626], ['2019-11-19T09:40:00Z', 2.71707167977236], ['2019-11-19T09:41:00Z', 7.531748826701985], ['2019-11-19T09:42:00Z', 9.060651847100033], ['2019-11-19T09:43:00Z', 7.538644905142789], ['2019-11-19T09:44:00Z', 2.6209794663899117]]}]}]} - """ if __name__ == "__main__": diff --git a/tests/test_redis_wrapper.py b/tests/test_redis_wrapper.py index dc3d2ed..3217733 100644 --- a/tests/test_redis_wrapper.py +++ b/tests/test_redis_wrapper.py @@ -5,6 +5,6 @@ class RedisTestCase(unittest.TestCase): def test_ping(self): - redis = BaseRedis('10.103.64.188') + redis = BaseRedis('127.0.0.1') print(redis.ping()) diff --git a/tests/test_smtp_wrapper.py b/tests/test_smtp_wrapper.py index 9a1a2b4..dc1df90 100644 --- a/tests/test_smtp_wrapper.py +++ b/tests/test_smtp_wrapper.py @@ -18,10 +18,10 @@ def test_sendtext(self): def test_sendattach(self): with BaseEmail() as email: email.sendmail( - frm="taf@gmail.com", + frm="user@domain.com", to=["canuxcheng@gmail.com"], cc=["canuxcheng@gmail.com"], - subject='taf test', + subject='test', text='i am text', files=['/home/canux/examples.desktop'] )