def test_check_permissions_to_run_SNAPSHOT_command(self):
        """
        Run snapshot utility SNAPSHOT command against all permissions configuration (see self.auth_creds).
        :return:
        """
        self.util_enable_server_security()
        self.start_grid()
        self.load_data_with_streamer()

        for auth_cred in self.auth_creds:
            self.su.snapshot_utility('SNAPSHOT', '-type=FULL')
            self.snapshot_ids[auth_cred] = self.get_last_snapshot_id()

        for auth_cred in self.auth_creds:
            self.util_enable_client_security(auth_cred)
            try:
                self.su.snapshot_utility('SNAPSHOT', '-type=FULL')
                self.snapshot_ids[auth_cred] = self.get_last_snapshot_id()
                print_green(
                    'Snapshot Utility SNAPSHOT command could be executed with "%s" credentials '
                    % auth_cred)

            except Exception as e:
                print_red(
                    'Snapshot Utility SNAPSHOT command could NOT be executed with "%s" credentials '
                    % auth_cred)
                pass
    def test_check_permissions_to_run_SCHEDULE_DELETE_command(self):
        """
        Run snapshot utility SCHEDULE -DELETE command against all permissions configuration (see self.auth_creds).
        :return:
        """
        self.util_enable_server_security()
        self.start_grid()

        for auth_cred in self.auth_creds:
            self.su.snapshot_utility('SCHEDULE', '-command=create',
                                     '-name=sys_sched_%s' % auth_cred,
                                     '-full_frequency=daily')

        for auth_cred in self.auth_creds:
            self.util_enable_client_security(auth_cred)
            try:
                self.su.snapshot_utility(
                    'SCHEDULE',
                    '-delete',
                    '-name=sys_sched_%s' % auth_cred,
                )
                print_green(
                    'Snapshot Utility SCHEDULE -delete command could be executed with "%s" credentials '
                    % auth_cred)
            except Exception as e:
                print_red(
                    'Snapshot Utility S0CHEDULE -create command could NOT be executed with "%s" credentials '
                    % auth_cred)
                pass
Exemple #3
0
    def util_find_snapshot_folders_on_fs(self, snapshot_id, remote_dir=None):
        snapshot_dirs = {}
        remote_snapshot_dir = None

        search_in_dir = remote_dir if remote_dir else './work/snapshot/'
        output = self.run_on_all_nodes('ls -1 %s | grep %s' %
                                       (search_in_dir, snapshot_id))

        if len(output) > 0:
            for node_idx in output.keys():
                snapshot_dir = output[node_idx].rstrip()
                if snapshot_dir:
                    # Add only if directory exists
                    snapshot_dirs[node_idx] = snapshot_dir
                    remote_snapshot_dir = snapshot_dirs[node_idx]
                print_green(
                    'Snapshot directory %s for snapshot ID=%s on node %s' %
                    (snapshot_dir if snapshot_dir else 'Not found',
                     snapshot_id, node_idx))

        # if remote dir, it is the same for all servers, so don't need to iterate over all servers
        if remote_dir:
            return '%s/%s' % (remote_dir, remote_snapshot_dir)

        return snapshot_dirs
Exemple #4
0
    def util_start_additional_nodes(self,
                                    node_type='server',
                                    add_to_baseline=False,
                                    nodes_ct=None):
        nodes_count = nodes_ct if nodes_ct else randint(1, 3)

        if node_type == 'server':
            config = self.get_server_config()
        else:
            config = self.get_client_config()

        additional_nodes = self.ignite.add_additional_nodes(
            config, nodes_count)
        self.start_additional_nodes(additional_nodes)

        baseline_msg = ''
        if add_to_baseline:
            self.cu.set_current_topology_as_baseline()
            baseline_msg = 'Server nodes added to baseline.'
            util_sleep_for_a_while(10)

        util_sleep_for_a_while(5)
        self.cu.control_utility('--baseline')
        print_green('Started %s %s nodes. %s' %
                    (nodes_count, node_type,
                     '' if not add_to_baseline else baseline_msg))

        return additional_nodes
Exemple #5
0
    def util_create_snapshots_chain(self, snapshots_count):
        snapshots_chain = []
        self.run_snapshot_utility('snapshot', '-type=full')

        for i in range(0, snapshots_count):
            print_green('Iteration %s from %s' % (i + 1, snapshots_count))
            self._remove_random_from_caches()

            self.run_snapshot_utility('snapshot')
            current_dump = self.calc_checksums_on_client()
            snapshots_chain.append(
                (self.get_latest_snapshot_id(), current_dump))
            self.load_data_with_streamer(end_key=5000, allow_overwrite=True)

        print_blue(self.su.snapshots_info())
        return snapshots_chain
    def test_check_permissions_to_run_LIST_command(self):
        """
        Run snapshot utility LIST command against all permissions configuration (see self.auth_creds).
        :return:
        """
        self.util_enable_server_security()
        self.start_grid()

        for auth_cred in self.auth_creds:
            self.util_enable_client_security(auth_cred)
            try:
                self.su.snapshot_utility('LIST')
                print_green(
                    'Snapshot Utility LIST command could be executed with "%s" credentials '
                    % auth_cred)
            except Exception as e:
                print_red(
                    'Snapshot Utility LIST command could NOT be executed with "%s" credentials '
                    % auth_cred)
                pass
Exemple #7
0
    def _create_dynamic_caches_with_data(self, with_index=False):
        log_print("Create dynamic caches and load data")

        data_model = ModelTypes.VALUE_ALL_TYPES.value
        created_caches = []
        with PiClient(self.ignite, self.get_client_config(),
                      nodes_num=1) as piclient:
            dynamic_caches_factory = DynamicCachesFactory()
            async_ops = []
            for method in dynamic_caches_factory.dynamic_cache_configs:
                cache_name = "cache_group_%s" % method
                print_green('Loading %s...' % cache_name)

                gateway = piclient.get_gateway()
                ignite = piclient.get_ignite()

                ignite.getOrCreateCache(
                    getattr(dynamic_caches_factory, method)(cache_name,
                                                            gateway=gateway))

                if with_index:
                    data_model = ModelTypes.VALUE_ALL_TYPES.value
                async_operation = create_async_operation(
                    create_streamer_operation,
                    cache_name,
                    1,
                    self.max_key + 2,
                    value_type=data_model)
                async_ops.append(async_operation)
                async_operation.evaluate()
                created_caches.append(cache_name)

            log_print('Waiting async results...', color='blue')
            # wait for streamer to complete
            for async_op in async_ops:
                async_op.getResult()

        log_print("Dynamic caches with data created")
        return created_caches
Exemple #8
0
 def util_print_checksum(self, checksum):
     if not self.get_context_variable('sbt_model_enabled'):
         print_green(checksum)