Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/653#discussion_r68495828
  
    --- Diff: iocore/hostdb/HostDB.cc ---
    @@ -2882,3 +2605,101 @@ ParseHostFile(char const *path, unsigned int 
hostdb_hostfile_check_interval)
       // Mark this one as completed, so we can allow another update to happen
       HostDBFileUpdateActive = 0;
     }
    +
    +//
    +// Regression tests
    +//
    +// Take a started hostDB and fill it up and make sure it doesn't explode
    +#ifdef TS_HAS_TESTS
    +struct HostDBRegressionContinuation;
    +typedef int (HostDBRegressionContinuation::*HostDBRegContHandler)(int, 
void *);
    +
    +struct HostDBRegressionContinuation : public Continuation {
    +  int hosts;
    +  const char **hostnames;
    +  RegressionTest *test;
    +  int type;
    +  int *status;
    +
    +  int success;
    +  int failure;
    +  int outstanding;
    +  int i;
    +
    +  int
    +  mainEvent(int event, HostDBInfo *r)
    +  {
    +    (void)event;
    +
    +    if (event == EVENT_INTERVAL) {
    +      rprintf(test, "hosts=%d success=%d failure=%d outstanding=%d 
i=%d\n", hosts, success, failure, outstanding, i);
    +    }
    +    if (event == EVENT_HOST_DB_LOOKUP) {
    +      --outstanding;
    +      // since this is a lookup done, data is either hostdbInfo or NULL
    +      if (r) {
    +        rprintf(test, "hostdbinfo r=%x\n", r);
    +        rprintf(test, "hostdbinfo hostname=%s\n", r->perm_hostname());
    +        rprintf(test, "hostdbinfo rr %x\n", r->rr());
    +        // If RR, print all of the enclosed records
    +        if (r->rr()) {
    +          rprintf(test, "hostdbinfo good=%d\n", r->rr()->good);
    +          for (int x = 0; x < r->rr()->good; x++) {
    +            ip_port_text_buffer ip_buf;
    +            ats_ip_ntop(r->rr()->info(x).ip(), ip_buf, sizeof(ip_buf));
    +            rprintf(test, "hostdbinfo RR%d ip=%s\n", x, ip_buf);
    +          }
    +        } else { // Otherwise, just the one will do
    +          ip_port_text_buffer ip_buf;
    +          ats_ip_ntop(r->ip(), ip_buf, sizeof(ip_buf));
    +          rprintf(test, "hostdbinfo A ip=%s\n", ip_buf);
    +        }
    +        ++success;
    +      } else {
    +        ++failure;
    +      }
    +    }
    +
    +    if (i < hosts) {
    +      hostDBProcessor.getbyname_re(this, hostnames[i++], 0);
    +      return EVENT_CONT;
    +    } else {
    +      rprintf(test, "HostDBTestRR: %d outstanding %d succcess %d 
failure\n", outstanding, success, failure);
    +      if (success == hosts) {
    +        *status = REGRESSION_TEST_PASSED;
    +      } else {
    +        *status = REGRESSION_TEST_FAILED;
    +      }
    +      return EVENT_DONE;
    +    }
    +  }
    +
    +  HostDBRegressionContinuation(int ahosts, const char **ahostnames, 
RegressionTest *t, int atype, int *astatus)
    +    : Continuation(new_ProxyMutex()),
    +      hosts(ahosts),
    +      hostnames(ahostnames),
    +      test(t),
    +      type(atype),
    +      status(astatus),
    +      success(0),
    +      failure(0),
    +      i(0)
    +  {
    +    outstanding = ahosts;
    +    
SET_HANDLER((HostDBRegContHandler)&HostDBRegressionContinuation::mainEvent);
    --- End diff --
    
    Remove unneeded cast.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to