Skip to content

Commit

Permalink
Merge pull request #2448 from desurd/mysmokes
Browse files Browse the repository at this point in the history
Add the smoke tests for reason form
  • Loading branch information
tardyp committed Dec 8, 2016
2 parents c3d6a40 + ec73486 commit c86127c
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 43 deletions.
33 changes: 33 additions & 0 deletions smokes/e2e/builder.coffee
@@ -0,0 +1,33 @@
# this file will contains the different generic functions which
# will be called by the different tests
# inspired by this methodology
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/

class builderPage
constructor: (builder, forcename) ->
@builderID = {
"runtest" : 1
"slowruntest": 2
}[builder]
@forceName=forcename

goDefault: ->
browser.get('#/builders')

go: () ->
browser.get('#/builders/#{@builderID}/')

goForce: (forcename) ->
browser.get("#/builders/#{@builderID}/force/#{@forceName}")

getBuildCount: () ->
return element.all(By.css('span.badge-status.results_SUCCESS')).count()

waitNextBuildFinished: (reference) ->
self = this
buildCountIncrement = () ->
self.getBuildCount().then (currentBuildCount) ->
return +currentBuildCount == +reference + 1
browser.wait(buildCountIncrement, 2000)

module.exports = builderPage
43 changes: 43 additions & 0 deletions smokes/e2e/force.coffee
@@ -0,0 +1,43 @@
# this file will contains the different generic functions which
# will be called by the different tests
# inspired by this methodology
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/

class forcePage
constructor: ->
browser.get('#/builders')

setInputText: (cssLabel, value) ->
setInputValue = element(By.css("forcefield label[for=#{cssLabel}] + div input"))
setInputValue.clear()
setInputValue.sendKeys(value)
expect(setInputValue.getAttribute('value')).toBe(value)

setReason: (reason) ->
return @setInputText("reason", reason)

setYourName: (yourName) ->
return @setInputText("username", yourName)

setProjectName: (projectName) ->
return @setInputText("project", projectName)

setBranchName: (branchName) ->
return @setInputText("branch", branchName)

setRepo: (repo) ->
return @setInputText("repository", repo)

setRevisionName: (RevisionName) ->
return @setInputText("revision", RevisionName)

getStartButton: ->
element(By.buttonText('Start Build'))

getCancelButton: ->
return element(By.buttonText('Cancel'))

getCancelWholeQueue: ->
element(By.buttonText('Cancel Whole Queue'))

module.exports = forcePage
45 changes: 29 additions & 16 deletions smokes/e2e/force.scenarios.coffee
@@ -1,16 +1,29 @@
describe 'force', () ->
it 'should create a build', () ->
browser.get('#/builders/1')
lastbuild = element.all(By.css('span.badge-status.results_SUCCESS')).count()
browser.get('#/builders/1/force/force')
browser.waitForAngular()
element(By.buttonText('Start Build')).click()
browser.get('#/builders/1')
successBuildIncrease = ->
lastbuild.then (lastbuild)->
element.all(By.css('span.badge-status.results_SUCCESS'))
.count().then (nextbuild)->
return +nextbuild == +lastbuild + 1
browser.wait(successBuildIncrease, 20000)
browser.get('#/waterfall')
expect(element.all(By.css('rect.success')).count()).toBeGreaterThan(0)
# coffee script
# test goal: checks the capability to define a reason and to cancel/start the build

forcePage = require('./force.coffee')
builderPage = require('./builder.coffee')

describe('', () ->
force = null
builder = null

beforeEach(() ->
builder = new builderPage('runtest', 'force')
force = new forcePage()
builder.goDefault()
)

lastbuild = null
describe 'force', () ->
it 'should create a build', () ->

lastbuild = 0
builder.go()
builder.getBuildCount().then (lastbuild) ->
builder.goForce()
force.getStartButton().click()
builder.go()
builder.waitNextBuildFinished(lastbuild)
expect(element.all(By.css('rect.success')).count()).toBeGreaterThan(0)
)
47 changes: 47 additions & 0 deletions smokes/e2e/reason_force.scenarios.coffee
@@ -0,0 +1,47 @@
# coffee script
# test goal: checks the capability to define a reason and to cancel/start the build


forcePage = require('./force.coffee')
builderPage = require('./builder.coffee')

describe('', () ->
force = null
builder = null

beforeEach(() ->
builder = new builderPage('runtest', 'force')
force = new forcePage()
builder.goDefault()
)

describe 'force', () ->
it 'should create a build', () ->
builder.go()
builder.getBuildCount().then (lastbuild) ->
builder.goForce()
force.getStartButton().click()
builder.go()
builder.waitNextBuildFinished(lastbuild)

describe 'forceandcancel', () ->
it 'should create a build with a dedicated reason and cancel it', () ->

builder.go()
builder.goForce()
force.getCancelButton().click()

describe 'forceandstart', () ->
it 'should create a build with a dedicated reason and Start it', () ->

builder.go()
builder.goForce()
force.setReason("New Test Reason")
force.setYourName("FaceLess User")
force.setProjectName("BBOT9")
force.setBranchName("Gerrit Branch")
force.setRepo("http//name.com")
force.setRevisionName("12345")
force.getStartButton().click()

)
13 changes: 13 additions & 0 deletions smokes/e2e/waterfall.coffee
@@ -0,0 +1,13 @@
# this file will contains the different generic functions which
# will be called by the different tests
# inspired by this methodology
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/

class waterfallPage
constructor: ->
browser.get('#/builders')

go: ->
browser.get('#/waterfall')

module.exports = waterfallPage
33 changes: 21 additions & 12 deletions smokes/master.cfg
Expand Up @@ -11,7 +11,6 @@ from buildbot.plugins import *
c = BuildmasterConfig = {}

####### WORKERS

# The 'workers' list defines the set of recognized workers. Each element is
# a Worker object, specifying a unique worker name and password. The same
# worker name and password must be configured on the worker.
Expand All @@ -24,19 +23,17 @@ c['workers'] = [worker.Worker("example-worker", "pass")]
# --master option)
c['protocols'] = {'pb': {'port': 9989}}

####### CHANGESOURCES

####### CHANGESOURCES
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes. Here we point to the buildbot clone of pyflakes.

c['change_source'] = []
c['change_source'].append(changes.GitPoller(
'https://github.com/buildbot/pyflakes.git',
workdir='gitpoller-workdir', branch='master',
pollinterval=300))

####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes. In this
# case, just kick off a 'runtests' build

Expand All @@ -45,13 +42,13 @@ c['schedulers'].append(schedulers.SingleBranchScheduler(
name="all",
change_filter=util.ChangeFilter(branch='master'),
treeStableTimer=None,
builderNames=["runtests"]))
builderNames=["runtests", "slowruntests"]))

c['schedulers'].append(schedulers.ForceScheduler(
name="force",
builderNames=["runtests"]))
builderNames=["runtests", "slowruntests"]))

####### BUILDERS

# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which workers can execute them. Note that any particular build will
# only take place on one worker.
Expand All @@ -62,22 +59,34 @@ factory.addStep(steps.Git(repourl='https://github.com/buildbot/pyflakes.git', mo
# run the tests (note that this will require that 'trial' is installed)
factory.addStep(steps.ShellCommand(command=["trial", "pyflakes"]))


slowfactory = util.BuildFactory()
#check out the source
slowfactory.addStep(steps.Git(repourl='https://github.com/buildbot/pyflakes.git', mode='incremental'))
# run the tests (note that this will require that 'trial' is installed)
slowfactory.addStep(steps.ShellCommand(command=["trial", "pyflakes"]))
slowfactory.addStep(steps.ShellCommand(command=["sleep", "30"]))



c['builders'] = []
c['builders'].append(
util.BuilderConfig(name="runtests",
workernames=["example-worker"],
factory=factory))
c['builders'].append(
util.BuilderConfig(name="slowruntests",
workernames=["example-worker"],
factory=slowfactory))

####### STATUS TARGETS

# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# like IRC bots.

c['status'] = []

####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').

Expand All @@ -91,17 +100,17 @@ c['titleURL'] = "https://launchpad.net/pyflakes"

c['buildbotURL'] = "http://localhost:8010/"



# minimalistic config to activate new web UI
c['www'] = dict(port=8010,
change_hook_dialects={'base': True},
plugins=dict(waterfall_view={}, console_view={}))

####### DB URL

####### DB URL
c['db'] = {
# This specifies what database buildbot uses to store its state. You can leave
# this at its default for all but the largest installations.
'db_url' : "sqlite:///state.sqlite",
}

c['buildbotNetUsageData'] = None
40 changes: 26 additions & 14 deletions smokes/package.json
@@ -1,16 +1,28 @@
{
"name": "smokes",
"version": "1.0.0",
"description": "smoke tests for buildbot with protractor",
"main": "index.js",
"dependencies": {
"coffee-script": "^1.11.1",
"protractor": "^4.0.3"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
"name": "smokes",
"version": "1.0.0",
"description": "smoke tests for buildbot with protractor",
"main": "index.js",
"dependencies": {
"coffee-script": "^1.11.1",
"protractor": "^4.0.3"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"coffeelintConfig": {
"indentation": {
"level": "error",
"value": 4
},
"max_line_length": {
"value": 110,
"level": "error",
"limitComments": true
}

},
"license": "ISC"
}
2 changes: 1 addition & 1 deletion smokes/protractor.conf.js
Expand Up @@ -12,7 +12,7 @@ exports.config = {
baseUrl: 'http://localhost:8010',

framework: 'jasmine',

jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
Expand Down

0 comments on commit c86127c

Please sign in to comment.