Example #1
0
void QosProcessorThreaded::testCheckNonOkRules()
{
    ruleDB_t *new_rules = NULL;
    
    try
    {
        
        log->log(ch, "starting testCheckNonOkRules");
        
        const string ruleFile = DEF_SYSCONFDIR "/example_rules2.xml";
        new_rules = rulem->parseRules(ruleFile);
    
        log->log(ch, "numRules %d", (int) new_rules->size() );
    

        log->log(ch, "after loading the rules");
        Event * evt = new checkRulesQoSProcessorEvent(*new_rules);
        qosProcessorPtr->addEvent(evt);
        
        // sleep waiting to execute the check method.
        unsigned int microseconds = 1000000;
        usleep(microseconds);
                
        eventVec_t e;
        qosProcessorPtr->handleFDEvent(&e, NULL, NULL, NULL);
        
        // We just have to have 1 new event.
        CPPUNIT_ASSERT( e.size() == 1 );
    
        ruleDBIter_t it;
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;      
            log->log(ch, "Rule %s.%s - Status:%d", rule->getSetName().c_str(), rule->getRuleName().c_str(), (int) rule->getState());
            CPPUNIT_ASSERT( rule->getState() == RS_ERROR );
        }


        // Release the memory created. 
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;
            saveDelete(rule);
        }

        saveDelete(new_rules);

        log->log(ch, "ending testCheckNonOkRules");
        
    }
    catch (Error &e)
    {
        cout << "Error:" << e.getError() << endl;
    }

}
Example #2
0
void QosProcessor_Test::testCheckNonOkRules()
{
    ruleDB_t *new_rules = NULL;

    try
    {

        log->log(ch, "starting testCheckNonOkRules");

        const string ruleFile = DEF_SYSCONFDIR "/example_rules2.xml";
        new_rules = rulem->parseRules(ruleFile);

        log->log(ch, "numRules %d", (int) new_rules->size() );

        qosProcessorPtr->checkRules(new_rules, evnt);

        ruleDBIter_t it;
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;
            log->log(ch, "Rule %s.%s - Status:%d", rule->getSetName().c_str(), rule->getRuleName().c_str(), (int) rule->getState());
            CPPUNIT_ASSERT( rule->getState() == RS_ERROR );
        }


        // Release the memory created.
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;
            saveDelete(rule);
        }

        saveDelete(new_rules);

        log->log(ch, "ending testCheckNonOkRules");

    }
    catch (Error &e)
    {
        cout << "Error:" << e.getError() << endl;
    }

}
Example #3
0
void Undo::saveDeletes(const QValueList<KAEvent> &events)
{
    int count = events.count();
    if(count == 1)
        saveDelete(events.first());
    else if(count > 1)
    {
        new UndoDeletes(UNDO, events);
        for(QValueList<KAEvent>::ConstIterator it = events.begin();  it != events.end();  ++it)
            removeRedos((*it).id());    // remove any redos which are made invalid by these deletions
        emitChanged();
    }
}
Example #4
0
void QosProcessorThreaded::testAddDeleteRules()
{


    ruleDB_t *new_rules = NULL;
    unsigned int microseconds = 1000000;
    Event * evt = NULL;
    eventVec_t eVec;
    
    try
    {
        
        log->log(ch, "starting testAddDeleteRules");
        
        const string ruleFile = DEF_SYSCONFDIR "/example_rules1.xml";
        new_rules = rulem->parseRules(ruleFile);
        
        qosProcessorPtr->checkRules(new_rules, evnt);
        
        ruleDBIter_t it;
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;      
            log->log(ch, "Rule %s.%s - Status:%d", rule->getSetName().c_str(), rule->getRuleName().c_str(), (int) rule->getState());
        }


        log->log(ch, "after loading the rules");
        evt = new addRulesQoSProcesorEvent(*new_rules);
        qosProcessorPtr->addEvent(evt);
        
        // sleep waiting to execute the check method.
        usleep(microseconds);
                
        qosProcessorPtr->handleFDEvent(&eVec, NULL, NULL, NULL);
        
        // We just have to have 1 new event.
        // One of the events corresponds to the answer, the other three correspond to activate events.
        CPPUNIT_ASSERT( eVec.size() == 4 );

        
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;      
            log->log(ch, "Rule %s.%s - Status:%d", rule->getSetName().c_str(), rule->getRuleName().c_str(), (int) rule->getState());
            CPPUNIT_ASSERT( rule->getState() == RS_ACTIVE );
        }


        log->log(ch, "after loading the rules");
        evt = new delRulesQoSProcesorEvent(*new_rules);
        qosProcessorPtr->addEvent(evt);
        
        // sleep waiting to execute the check method.
        usleep(microseconds);
                
        qosProcessorPtr->handleFDEvent(&eVec, NULL, NULL, NULL);
        
        // We just have to have 1 new event.
        CPPUNIT_ASSERT( eVec.size() == 5);

        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;      
            log->log(ch, "Rule %s.%s - Status:%d", rule->getSetName().c_str(), rule->getRuleName().c_str(), (int) rule->getState());
            CPPUNIT_ASSERT( rule->getState() == RS_DONE );
        }


        // Release the memory created. 
        for (it = new_rules->begin(); it != new_rules->end(); ++it)
        {
            Rule *rule = *it;
            saveDelete(rule);
        }

        saveDelete(new_rules);

        log->log(ch, "ending testAddDeleteRules");
        
    }
    catch (Error &e)
    {
        cout << "Error:" << e.getError() << endl;
    }
    

}