Skip to content

Commit

Permalink
Push crystalball map to s3 in crystalball-map job
Browse files Browse the repository at this point in the history
closes OUT-4895
flag=none

Test-plan:
- after job builds, new map should be visible in instructure-canvas-ci
  bucket

Change-Id: I3fa98f1da7e4b75f6b24dedff5a9cb35c3e08eb6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/280200
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: James Butters <[email protected]>
QA-Review: Brian Watson <[email protected]>
Product-Review: Brian Watson <[email protected]>
  • Loading branch information
brianlwatson committed Dec 6, 2021
1 parent 6102c92 commit 37b2bf1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile.crystalball
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pipeline {

sh 'docker cp crystalball-parser:/usr/src/app/crystalball_map.yml .'
archiveArtifacts allowEmptyArchive: true, artifacts: 'crystalball_map.yml'
sh 'aws s3 cp crystalball_map.yml s3://instructure-canvas-ci/'

// Only alert on periodic jobs, not ones resulting from manual tests
if (env.GERRIT_EVENT_TYPE != 'comment-added') {
Expand Down
36 changes: 29 additions & 7 deletions build/new-jenkins/library/vars/rspecStage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def createDistribution(nestedStages) {
"RSPECQ_UPDATE_TIMINGS=${env.GERRIT_EVENT_TYPE == 'change-merged' ? '1' : '0'}",
]

// Used only for crystalball map generation
def seleniumNodeTotal = configuration.getInteger('selenium-ci-node-total')
def seleniumEnvVars = baseEnvVars + [
"CI_NODE_TOTAL=$seleniumNodeTotal",
'COMPOSE_FILE=docker-compose.new-jenkins.yml:docker-compose.new-jenkins-selenium.yml',
'EXCLUDE_TESTS=.*/performance',
"FORCE_FAILURE=${configuration.isForceFailureSelenium() ? '1' : ''}",
"RERUNS_RETRY=${configuration.getInteger('selenium-rerun-retry')}",
"RSPEC_PROCESSES=${configuration.getInteger('selenium-processes')}",
'TEST_PATTERN=^./(spec|gems/plugins/.*/spec_canvas)/selenium',
]

def rspecNodeRequirements = [label: 'canvas-docker']

extendedStage('RSpecQ Reporter for Rspec')
Expand All @@ -55,13 +67,24 @@ def createDistribution(nestedStages) {
.timeout(15)
.queue(nestedStages, this.&runReporter)

rspecqNodeTotal.times { index ->
extendedStage("RSpecQ Test Set ${(index + 1).toString().padLeft(2, '0')}")
.envVars(rspecqEnvVars + ["CI_NODE_INDEX=$index"])
.hooks(buildSummaryReportHooks.call() + [onNodeAcquired: setupNodeHook, onNodeReleasing: { tearDownNode('spec') }])
if (env.ENABLE_CRYSTALBALL != '1') {
rspecqNodeTotal.times { index ->
extendedStage("RSpecQ Test Set ${(index + 1).toString().padLeft(2, '0')}")
.envVars(rspecqEnvVars + ["CI_NODE_INDEX=$index"])
.hooks(buildSummaryReportHooks.call() + [onNodeAcquired: setupNodeHook, onNodeReleasing: { tearDownNode('spec') }])
.nodeRequirements(rspecNodeRequirements)
.timeout(15)
.queue(nestedStages, this.&runRspecqSuite)
}
} else {
seleniumNodeTotal.times { index ->
extendedStage("Selenium Test Set ${(index + 1).toString().padLeft(2, '0')}")
.envVars(seleniumEnvVars + ["CI_NODE_INDEX=$index"])
.hooks([onNodeAcquired: setupNodeHook, onNodeReleasing: { tearDownNode('selenium') }])
.nodeRequirements(rspecNodeRequirements)
.timeout(15)
.queue(nestedStages, this.&runRspecqSuite)
.queue(nestedStages, this.&runLegacySuite)
}
}
}

Expand Down Expand Up @@ -104,8 +127,7 @@ def tearDownNode(prefix) {
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results tmp/rspec_results canvas_ --allow-error --clean-dir'
sh "build/new-jenkins/docker-copy-files.sh /usr/src/app/log/spec_failures/ tmp/spec_failures/$prefix canvas_ --allow-error --clean-dir"

// Don't generate map pre-merge
if (env.ENABLE_CRYSTALBALL == '1' && env.RSPECQ_ENABLED != '1') {
if (env.ENABLE_CRYSTALBALL == '1') {
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results/crystalball_results tmp/crystalball canvas_ --allow-error --clean-dir'
sh 'ls tmp/crystalball'
sh 'ls -R'
Expand Down
23 changes: 11 additions & 12 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,22 @@ def view_assigns
end
end

# Don't do map generation in pre-merge, which runs rspecq
if ENV["ENABLE_CRYSTALBALL"] == "1" && ENV["RSPECQ_ENABLED"] != "1"
if ENV["ENABLE_CRYSTALBALL"] == "1"
Crystalball::MapGenerator.start! do |config|
config.register Crystalball::MapGenerator::CoverageStrategy.new
config.map_storage_path = "log/results/crystalball_results/#{ENV.fetch("PARALLEL_INDEX", "0")}_map.yml"
end
end

module Crystalball
class MapGenerator
class CoverageStrategy
def call(example_map, example)
puts "Calling Coverage Strategy for #{example.inspect}"
before = Coverage.peek_result
yield example_map, example
after = Coverage.peek_result
example_map.push(*execution_detector.detect(before, after))
module Crystalball
class MapGenerator
class CoverageStrategy
def call(example_map, example)
puts "Calling Coverage Strategy for #{example.inspect}"
before = Coverage.peek_result
yield example_map, example
after = Coverage.peek_result
example_map.push(*execution_detector.detect(before, after))
end
end
end
end
Expand Down

0 comments on commit 37b2bf1

Please sign in to comment.