def test_gnocchi(self): port = gnocchi.GnocchiDriver.DEFAULT_PORT self.useFixture(gnocchi.GnocchiDriver()) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)
def test_gnocchi_with_redis_coordinator(self): self.useFixture( gnocchi.GnocchiDriver(coordination_driver="redis", port=8043)) self.assertEqual("gnocchi://localhost:%d" % 8043, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % 8043) self.assertEqual(200, r.status_code)
def test_gnocchi_with_existing_swift(self): self.useFixture(swift.SwiftDriver()) self.useFixture( gnocchi.GnocchiDriver(storage_url=os.getenv("PIFPAF_URL"))) self.assertEqual("gnocchi://localhost:8041", os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:8041/") self.assertEqual(200, r.status_code)
def test_gnocchi_with_existing_indexer(self): port = gnocchi.GnocchiDriver.DEFAULT_PORT + 15 pg = self.useFixture(postgresql.PostgreSQLDriver(port=9833)) self.useFixture(gnocchi.GnocchiDriver(indexer_url=pg.url, port=port)) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)
def test_gnocchi_legacy(self): port = gnocchi.GnocchiDriver.DEFAULT_PORT + 10 self.useFixture( gnocchi.GnocchiDriver(create_legacy_resource_types=True, port=port, indexer_port=8143)) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)
def test_gnocchi_with_existing_s3rver(self): s3 = self.useFixture(s3rver.S3rverDriver(port=4569)) port = gnocchi.GnocchiDriver.DEFAULT_PORT + 12 self.useFixture(gnocchi.GnocchiDriver( storage_url="s3://gnocchi:pass@localhost:%d" % s3.port, port=port)) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)
def _setUp(self): super(AodhDriver, self)._setUp() with open(self.find_config_file("aodh/api_paste.ini"), "r") as src: with open(os.path.join(self.tempdir, "api_paste.ini"), "w") as dst: for line in src.readlines(): if line.startswith("pipeline = "): dst.write("pipeline = request_id api-server") else: dst.write(line) shutil.copy(self.find_config_file("aodh/policy.json"), self.tempdir) pg = self.useFixture( postgresql.PostgreSQLDriver(port=self.database_port)) g = self.useFixture( gnocchi.GnocchiDriver( port=self.gnocchi_port, indexer_port=self.gnocchi_indexer_port, create_legacy_resource_types=( self.gnocchi_create_legacy_resource_types), )) conffile = os.path.join(self.tempdir, "aodh.conf") user = str(uuid.uuid4()) project = str(uuid.uuid4()) with open(conffile, "w") as f: f.write("""[database] connection = %s [api] port = %d [service_credentials] auth_type = gnocchi-noauth user_id = %s project_id = %s roles = admin endpoint = %s""" % (pg.url, self.port, user, project, g.http_url)) self._exec(["aodh-dbsync", "--config-file=%s" % conffile]) c, _ = self._exec( ["aodh-api", "--config-file=%s" % conffile], wait_for_line=b"Running on http://0.0.0.0") self.addCleanup(self._kill, c.pid) self.putenv("PIFPAF_AODH_PORT", str(self.port)) self.putenv("PIFPAF_AODH_GNOCCHI_USER_ID", user) self.putenv("PIFPAF_AODH_GNOCCHI_PROJECT_ID", project) self.putenv("PIFPAF_URL", "aodh://localhost:%d" % self.port) self.putenv("PIFPAF_AODH_HTTP_URL", "http://localhost:%d" % self.port)
def test_gnocchi_with_existing_ceph(self): port = gnocchi.GnocchiDriver.DEFAULT_PORT + 10 tmp_rootdir = self._get_tmpdir_for_xattr() ceph_driver = ceph.CephDriver(tmp_rootdir=tmp_rootdir) self.useFixture(ceph_driver) ceph_driver._exec(["rados", "-c", os.getenv("CEPH_CONF"), "mkpool", "gnocchi"]), self.useFixture(gnocchi.GnocchiDriver( storage_url="ceph://%s" % os.getenv("CEPH_CONF"), port=port)) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)
def _setUp(self): super(AodhDriver, self)._setUp() if self.database_url is None: pg = self.useFixture( postgresql.PostgreSQLDriver(port=self.database_port)) self.database_url = pg.url g = self.useFixture( gnocchi.GnocchiDriver( port=self.gnocchi_port, indexer_port=self.gnocchi_indexer_port, )) conffile = os.path.join(self.tempdir, "aodh.conf") with open(conffile, "w") as f: f.write("""[database] connection = %s [api] auth_mode= [service_credentials] auth_type = gnocchi-basic user = admin endpoint = %s""" % (self.database_url, g.http_url)) self._exec(["aodh-dbsync", "--config-file=%s" % conffile]) c, _ = self._exec([ "aodh-api", "--port", str(self.port), "--", "--config-file=%s" % conffile ], wait_for_line="Available at http://") self.addCleanup(self._kill, c) c, _ = self._exec( ["aodh-evaluator", "--config-file=%s" % conffile], wait_for_line="initiating evaluation cycle") self.addCleanup(self._kill, c) self.putenv("AODH_PORT", str(self.port)) self.putenv("AODH_GNOCCHI_USER", "admin") self.putenv("URL", "aodh://localhost:%d" % self.port) url = "http://localhost:%d" % self.port self.putenv("AODH_HTTP_URL", url) self.putenv("AODH_ENDPOINT", url, True)
def test_gnocchi_with_existing_ceph(self): port = gnocchi.GnocchiDriver.DEFAULT_PORT + 10 tempdir = self.useFixture(fixtures.TempDir()).path ceph_driver = ceph.CephDriver() try: ceph_driver._ensure_xattr_support(tempdir) except RuntimeError as e: self.skipTest(str(e)) self.useFixture(ceph_driver) ceph_driver._exec( ["rados", "-c", os.getenv("CEPH_CONF"), "mkpool", "gnocchi"]), self.useFixture( gnocchi.GnocchiDriver(storage_url="ceph://%s" % os.getenv("CEPH_CONF"), port=port)) self.assertEqual("gnocchi://localhost:%d" % port, os.getenv("PIFPAF_URL")) r = requests.get("http://localhost:%d/" % port) self.assertEqual(200, r.status_code)