Closed Bug 1184851 Opened 10 years ago Closed 7 years ago

Add mock publisher and stats drain to taskcluster-base

Categories

(Taskcluster :: Services, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: mrrrgn, Unassigned)

Details

It's difficult to write pure unit tests for taskcluster right now, since using the publisher requires a pulse account, and the stats drain requires an influxdb instance. Simply stubbing out these objects is possible, but that, in turn, makes it impossible to access features/data which would be desirable (e.g. schema validation). As per discussion on: https://github.com/taskcluster/taskcluster-github/pull/1 "I'm not oppose to these things. But stubbing out the publisher means that you skip validation etc... and it very quickly becomes rather boring... So if we really want to do something like this, perhaps we should add an option to base.Exchanges such that a boolean config option can be used to get a dummy publisher that just validates messages and emits them as events on the process object. We should probably do the same for stats.Influx, such that it looks like: statsDrain = new base.stats.Influx({ connectionString: cfg.get('influx:connectionString'), // then in config/test.js, set influx:connectionString = "null" // and modify base.stats.Influx such that connectionString means it will print stats as debug messages // and emit them as events on the process object. maxDelay: cfg.get('influx:maxDelay'), maxPendingPoints: cfg.get('influx:maxPendingPoints') });" We should either 1.) add an offline mode to the publisher/influx objects or 2.) creates official mock versions of these objects.
I think this is a good idea. Note, we already have a mock version for influx called NullDrain. But it adds extra code to everywhere when we add if (useMock) {drain = NullDrain()} else { drain = Influx(...)} (and this is boring duplicated code, the worst kind of code!) So having it as a configuration option, or special connectionString, would reduce complications and we would be able to set the mode from a configuration profile. IMO, integration tests are valuable, but since Influx and Exchange bindings are so heavily tested in taskcluster-base, giving them an "offline" mode, seems pretty reasonable. In both cases we still want type/schema validation, etc.
Component: General → Platform Libraries
Component: Platform Libraries → Platform and Services
I think dustin did some of this already... regardless the code have been refactored since, let's close.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Component: Platform and Services → Services
You need to log in before you can comment on or make changes to this bug.