LOGGER.info(self.initialLoggingString, metricName) # Get path to data knownDataFilePath = self._getPathToData(knownDataFile) # Load and send data sock = self._getSocketConnection() LOGGER.info("Sending data from %s ...", knownDataFile) labels = self._loadAndSendData(sock, knownDataFilePath, metricName) # Make sure the metric was properly created and wait for the expected # records to be stored. NOTE: Waiting for all records to be stored # facilitates constistent stats calculation in Grok, resulting in # consistency of results from one run of the test to the next. uid = self.checkMetricCreated(metricName, numRecords=len(labels)) # Save the uid for later LOGGER.info("Metric %s has uid: %s", metricName, uid) # Send model creation request self._createModel(uid) return self._verifyResults(uid, metricName, knownDataFilePath, labels, expectedResults) if __name__ == "__main__": unittest.main()
modelId = adapter.importModel(spec) newModelSpec = dict(modelSpec) with self.engine.connect() as conn: repository.getMetric(conn, modelId) autostack = repository.getAutostackFromMetric(conn, modelId) self.addCleanup(self._deleteAutostack, autostack.uid) newModelSpec["metricSpec"]["autostackId"] = autostack.uid self.validateModel(modelId, modelSpec, autostack) def validateModel(self, modelId, modelSpec, autostack): self.assertIsNotNone(modelId) with self.engine.connect() as conn: metricObj = repository.getMetric( conn, modelId, fields=[schema.metric.c.status, schema.metric.c.parameters]) self.assertIn(metricObj.status, [MetricStatus.CREATE_PENDING, MetricStatus.ACTIVE]) self.assertEqual(json.loads(metricObj.parameters), modelSpec) self.assertEqual( repository.getAutostackFromMetric(conn, modelId).uid, autostack.uid) if __name__ == "__main__": unittest.main()