Esempio n. 1
0
def scan_all_servers():
    from java.time import Duration
    from com.couchbase.client.java import Cluster, ClusterOptions
    from com.couchbase.client.java.env import ClusterEnvironment
    from com.couchbase.client.core.env import TimeoutConfig, IoConfig
    cluster_env = ClusterEnvironment.builder().ioConfig(IoConfig.numKvConnections(25)).timeoutConfig(TimeoutConfig.builder().connectTimeout(Duration.ofSeconds(20)).kvTimeout(Duration.ofSeconds(10)))
    cluster_options = ClusterOptions.clusterOptions("Administrator", "esabhcuoc").environment(cluster_env.build())
    cluster = Cluster.connect("172.23.104.162", cluster_options)
    STATEMENT = "select meta().id from `QE-server-pool` where os='centos' and '12hrreg' in poolId or 'regression' in poolId or 'magmareg' in poolId;"
    result = cluster.query(STATEMENT);

    count = 1
    for server in result.rowsAsObject():
        print "--+--+--+--+-- {}. CHECKING ON SERVER: {} --+--+--+--+--".format(count, server.get("id"))
        count += 1
        check_coredump_exist(server.get("id"))
Esempio n. 2
0
def execute(cmd="free -m"):
    cluster_env = ClusterEnvironment.builder().ioConfig(IoConfig.numKvConnections(25)).timeoutConfig(TimeoutConfig.builder().connectTimeout(Duration.ofSeconds(20)).kvTimeout(Duration.ofSeconds(10)))
    cluster_options = ClusterOptions.clusterOptions("Administrator", "esabhcuoc").environment(cluster_env.build())
    cluster = Cluster.connect("172.23.104.162", cluster_options)
    STATEMENT = "select meta().id from `QE-server-pool` where os='centos' and '12hrreg' in poolId or 'regression' in poolId or 'magmareg' in poolId;"
    result = cluster.query(STATEMENT);

    count = 1
    for server in result.rowsAsObject():
        server = server.get("id")
        print("--+--+--+--+-- %s. SERVER: %s --+--+--+--+--" % (count, server))
        count += 1
        output, error = run(cmd, server)
        if output:
            print(output)
        if error:
            print(error)
Esempio n. 3
0
 def _createConn(self):
     try:
         self.log.debug("Creating cluster connection")
         System.setProperty("com.couchbase.forceIPv4", "false")
         logger = Logger.getLogger("com.couchbase.client")
         logger.setLevel(Level.SEVERE)
         for h in logger.getParent().getHandlers():
             if isinstance(h, ConsoleHandler):
                 h.setLevel(Level.SEVERE)
         cluster_env = ClusterEnvironment \
                       .builder(", ".join(self.hosts).replace(" ", ""),
                                self.username, self.password) \
                       .timeoutConfig(TimeoutConfig.builder()
                                      .connectTimeout(Duration.ofSeconds(20))
                                      .kvTimeout(Duration.ofSeconds(10)))
         self.cluster = Cluster.connect(cluster_env.build())
         self.bucketObj = self.cluster.bucket(self.bucket)
         self.collection = self.bucketObj.defaultCollection()
     except Exception as e:
         raise Exception("SDK Connection error: " + str(e))
Esempio n. 4
0
 def connectCluster(self, username=None, password=None):
     if username:
         self.username = username
     if password:
         self.password = password
     try:
         System.setProperty("com.couchbase.forceIPv4", "false")
         logger = Logger.getLogger("com.couchbase.client")
         logger.setLevel(Level.SEVERE)
         for h in logger.getParent().getHandlers():
             if isinstance(h, ConsoleHandler):
                 h.setLevel(Level.SEVERE)
         self.cluster = Cluster.connect(
             ClusterEnvironment.builder(
                 ",".join(self.server.ip), self.username,
                 self.password).timeoutConfig(
                     TimeoutConfig.builder().kvTimeout(
                         Duration.ofSeconds(10))).build())
     except CouchbaseException:
         print "cannot login from user: %s/%s" % (self.username,
                                                  self.password)
         raise
Esempio n. 5
0
def find_rerun_job(args):
    """
    Find if the job was run previously
    :param args: Dictionary of arguments. Run build_args() if calling
    this from python script or parse_args() if running from shell
    :type args: dict
    :return: If the job was run previously. If yes the re_run
    document from the server
    :rtype: (bool, dict)
    """
    name = None
    store_data = args['store_data']
    install_failure = args['install_failure']
    if args['executor_jenkins_job']:
        os = OS.getenv('os')
        component = OS.getenv('component')
        sub_component = OS.getenv('subcomponent')
        version_build = OS.getenv('version_number')
        name = "{}_{}_{}".format(os, component, sub_component)
    elif args['jenkins_job']:
        name = OS.getenv('JOB_NAME')
        version_build = args['build_version']
    else:
        os = args['os']
        component = args['component']
        sub_component = args['sub_component']
        if os and component and sub_component:
            name = "{}_{}_{}".format(os, component, sub_component)
        elif args['name']:
            name = args['name']
        version_build = args['build_version']
    if not name or not version_build:
        return False, {}
    cluster = Cluster.connect(host, 'Administrator', 'password')
    rerun_jobs = cluster.bucket(bucket_name)
    collection = rerun_jobs.defaultCollection()
    time.sleep(10)
    rerun = False
    doc_id = "{}_{}".format(name, version_build)
    try:
        success, run_document = get_document(collection, doc_id)
        if not store_data:
            if not success:
                return False, {}
            else:
                return True, run_document
        parameters = jenkins_api.get_params(OS.getenv('BUILD_URL'))
        run_results = get_run_results()
        job_to_store = {
            "job_url": OS.getenv('BUILD_URL'),
            "build_id": OS.getenv('BUILD_ID'),
            "run_params": parameters,
            "run_results": run_results,
            "install_failure": install_failure
        }
        if success:
            rerun = True
        else:
            run_document = {"build": version_build, "num_runs": 0, "jobs": []}
        run_document['num_runs'] += 1
        run_document['jobs'].append(job_to_store)
        upsert_document(collection, doc_id, run_document)
        return rerun, run_document
    except Exception as e:
        print(e)
        return False, {}