func (s *MySuite) TestDistributionOfSpecsWithMoreNumberOfDistributions(c *C) {
	specs := createSpecsList(6)
	specCollections := filter.DistributeSpecs(specs, 10)
	c.Assert(len(specCollections), Equals, 6)
	verifySpecCollectionsForSize(c, 1, specCollections...)

	specCollections = filter.DistributeSpecs(specs, 17)
	c.Assert(len(specCollections), Equals, 6)
	verifySpecCollectionsForSize(c, 1, specCollections...)

	specCollections = filter.DistributeSpecs(createSpecsList(0), 17)
	c.Assert(len(specCollections), Equals, 0)
}
func (s *MySuite) TestDistributionOfSpecsWithMoreNumberOfDistributions(c *C) {
	specs := createSpecsList(6)
	e := parallelSpecExecution{numberOfExecutionStreams: 10, specifications: specs}
	specCollections := filter.DistributeSpecs(specs, e.getNumberOfStreams())
	c.Assert(len(specCollections), Equals, 6)
	verifySpecCollectionsForSize(c, 1, specCollections...)

	e.numberOfExecutionStreams = 17
	specCollections = filter.DistributeSpecs(specs, e.getNumberOfStreams())
	c.Assert(len(specCollections), Equals, 6)
	verifySpecCollectionsForSize(c, 1, specCollections...)

	e.numberOfExecutionStreams = 17
	specs = createSpecsList(0)
	e.specifications = specs
	specCollections = filter.DistributeSpecs(specs, e.getNumberOfStreams())
	c.Assert(len(specCollections), Equals, 0)
}
Esempio n. 3
0
func (e *parallelExecution) executeEagerly(distributions int, resChan chan *result.SuiteResult) {
	specs := filter.DistributeSpecs(e.specCollection.Specs(), distributions)
	e.wg.Add(distributions)
	for i, s := range specs {
		go e.startSpecsExecution(s, reporter.NewParallelConsole(i+1), resChan)
	}
	e.wg.Wait()
	close(resChan)
}
func (s *MySuite) TestDistributionOfSpecs(c *C) {
	specs := createSpecsList(10)
	specCollections := filter.DistributeSpecs(specs, 10)
	c.Assert(len(specCollections), Equals, 10)
	verifySpecCollectionsForSize(c, 1, specCollections...)

	specCollections = filter.DistributeSpecs(specs, 5)
	c.Assert(len(specCollections), Equals, 5)
	verifySpecCollectionsForSize(c, 2, specCollections...)

	specCollections = filter.DistributeSpecs(specs, 4)
	c.Assert(len(specCollections), Equals, 4)
	verifySpecCollectionsForSize(c, 3, specCollections[:2]...)
	verifySpecCollectionsForSize(c, 2, specCollections[2:]...)

	specCollections = filter.DistributeSpecs(specs, 3)
	c.Assert(len(specCollections), Equals, 3)
	verifySpecCollectionsForSize(c, 4, specCollections[0])
	verifySpecCollectionsForSize(c, 3, specCollections[1:]...)
}
Esempio n. 5
0
func (e *parallelSpecExecution) eagerExecution(distributions int) []*result.SuiteResult {
	specCollections := filter.DistributeSpecs(e.specifications, distributions)
	suiteResultChannel := make(chan *result.SuiteResult, len(specCollections))
	for i, specCollection := range specCollections {
		go e.startSpecsExecution(specCollection, suiteResultChannel, logger.NewParallelLogger(i+1))
	}
	suiteResults := make([]*result.SuiteResult, 0)
	for _, _ = range specCollections {
		suiteResults = append(suiteResults, <-suiteResultChannel)
	}
	return suiteResults
}
Esempio n. 6
0
func (e *parallelExecution) eagerExecution(distributions int) []*result.SuiteResult {
	specCollections := filter.DistributeSpecs(e.specStore.specs, distributions)
	suiteResultChannel := make(chan *result.SuiteResult, len(specCollections))
	for i, specCollection := range specCollections {
		go e.startSpecsExecution(specCollection, suiteResultChannel, reporter.NewParallelConsole(i+1))
	}
	var suiteResults []*result.SuiteResult
	for _ = range specCollections {
		suiteResults = append(suiteResults, <-suiteResultChannel)
	}
	return suiteResults
}
Esempio n. 7
0
func (e *parallelSpecExecution) start() *result.SuiteResult {
	startTime := time.Now()
	specCollections := filter.DistributeSpecs(e.specifications, e.numberOfExecutionStreams)
	suiteResultChannel := make(chan *result.SuiteResult, len(specCollections))
	for i, specCollection := range specCollections {
		go e.startSpecsExecution(specCollection, suiteResultChannel, nil, execLogger.NewParallelExecutionConsoleWriter(i+1))
	}
	e.writer.Info("Executing in %s parallel streams.", strconv.Itoa(len(specCollections)))
	suiteResults := make([]*result.SuiteResult, 0)
	for _, _ = range specCollections {
		suiteResults = append(suiteResults, <-suiteResultChannel)
	}

	e.aggregateResult = e.aggregateResults(suiteResults)
	e.aggregateResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	e.aggregateResult.ProjectName = filepath.Base(config.ProjectRoot)
	e.aggregateResult.Environment = env.CurrentEnv
	e.aggregateResult.Tags = ExecuteTags
	e.aggregateResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return e.aggregateResult
}