source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/deploy/production.example.rb | Ruby | apache-2.0 | 45 | master | 757 | # frozen_string_literal: true
# See deploy.rb for more options
set :rails_env, :production # dont try and infer something as important as environment from stage name.
server 'CWB_SERVER_IP', user: 'deploy', roles: %w{web app db}
set :delayed_job_workers, 2
# Manually assign a new password via 'cap production user:cha... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/environments/development.rb | Ruby | apache-2.0 | 45 | master | 2,635 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Add Rack::LiveReload to the bottom of the middleware stack with the default options.
config.middleware.use Rack::LiveReload
# In the development environment your ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/environments/production.rb | Ruby | apache-2.0 | 45 | master | 4,552 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, a... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/environments/test.rb | Ruby | apache-2.0 | 45 | master | 2,564 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "s... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/devise.rb | Ruby | apache-2.0 | 45 | master | 12,657 | # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inv... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/string_extension.rb | Ruby | apache-2.0 | 45 | master | 296 | # frozen_string_literal: true
class String
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError.new("Invalid value for String-Boolean: \"#{self}\"")
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/delayed_job_config.rb | Ruby | apache-2.0 | 45 | master | 534 | # frozen_string_literal: true
# config/initializers/delayed_job_config.rb
# see https://github.com/collectiveidea/delayed_job
Delayed::Worker.backend = :active_record
Delayed::Worker.destroy_failed_jobs = true
Delayed::Worker.sleep_delay = 5
Delayed::Worker.max_attempts = 1
Delayed::Worker.max_run_time = 4.hours
Delay... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/time_formats.rb | Ruby | apache-2.0 | 45 | master | 578 | # frozen_string_literal: true
# DateTime format docs: http://apidock.com/ruby/DateTime/strftime
# Example: 2014-06-29 11:35:41
Time::DATE_FORMATS[:date_and_time_long] = '%Y-%m-%d %H:%M:%S'
# Example: 2014-06-29 11:35
Time::DATE_FORMATS[:date_and_time_short] = '%Y-%m-%d %H:%M'
# Example: 2014-06-29
Time::DATE_FORMATS[... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/new_framework_defaults_5_2.rb | Ruby | apache-2.0 | 45 | master | 1,900 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.2 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Ma... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/new_framework_defaults_5_1.rb | Ruby | apache-2.0 | 45 | master | 623 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.1 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Ma... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/secret_token.rb | Ruby | apache-2.0 | 45 | master | 1,392 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/simple_form.rb | Ruby | apache-2.0 | 45 | master | 5,753 | # frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | config/initializers/simple_form_bootstrap.rb | Ruby | apache-2.0 | 45 | master | 1,700 | # frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.input_class = 'form-control'
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :la... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/benchmark_schedules_controller.rb | Ruby | apache-2.0 | 45 | master | 2,733 | # frozen_string_literal: true
class BenchmarkSchedulesController < ApplicationController
before_action :set_benchmark_schedule, only: [:edit, :update, :activate, :deactivate]
before_action :set_benchmark_definition, only: [:new, :create]
def new
@benchmark_schedule = @benchmark_definition.build_benchmark_sc... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/nominal_metric_observations_controller.rb | Ruby | apache-2.0 | 45 | master | 471 | # frozen_string_literal: true
class NominalMetricObservationsController < ApplicationController
before_action :set_metric_observation, only: [:destroy]
def destroy
@nominal_metric_observation.destroy
redirect_back(fallback_location: root_path)
end
private
# Use callbacks to share common setup or ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/benchmark_definitions_controller.rb | Ruby | apache-2.0 | 45 | master | 3,249 | # frozen_string_literal: true
class BenchmarkDefinitionsController < ApplicationController
include BenchmarkDefinitionsHelper
before_action :set_benchmark_definition, only: [:show, :edit, :update, :destroy]
before_action :check_and_show_executions_integrity_warning, only: [:edit, :update]
def index
@bench... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/errors_controller.rb | Ruby | apache-2.0 | 45 | master | 451 | # frozen_string_literal: true
class ErrorsController < ApplicationController
skip_before_action :authenticate_user!, raise: false
skip_before_action :verify_authenticity_token
# NOTE: Consider using a failsafe errors layout
# layout 'errors'
def show
render status: status_code, template: "errors/#{statu... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/benchmark_executions_controller.rb | Ruby | apache-2.0 | 45 | master | 3,549 | # frozen_string_literal: true
class BenchmarkExecutionsController < ApplicationController
PRIORITY_HIGH = 1
API_METHODS = [:prepare_log, :release_resources_log]
before_action :authenticate_user!, except: API_METHODS
before_action :set_benchmark_definition, only: [:new, :create]
before_action :set_benchmark_e... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/metric_definitions_controller.rb | Ruby | apache-2.0 | 45 | master | 1,893 | # frozen_string_literal: true
class MetricDefinitionsController < ApplicationController
before_action :set_metric_definition, only: [:edit, :update, :destroy]
before_action :set_benchmark_definition, only: [:new, :create]
before_action :check_and_show_observations_integrity_warning, only: [:edit, :update]
def... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/ordered_metric_observations_controller.rb | Ruby | apache-2.0 | 45 | master | 487 | # frozen_string_literal: true
class OrderedMetricObservationsController < ApplicationController
before_action :set_ordered_metric_observation, only: [:destroy]
def destroy
@ordered_metric_observation.destroy
redirect_back(fallback_location: root_path)
end
private
# Use callbacks to share common s... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/virtual_machine_instances_controller.rb | Ruby | apache-2.0 | 45 | master | 2,022 | # frozen_string_literal: true
class VirtualMachineInstancesController < ApplicationController
API_METHODS = [:complete_benchmark, :complete_postprocessing]
before_action :authenticate_user!, except: API_METHODS
protect_from_forgery except: API_METHODS
before_action :set_virtual_machine_instance, only: [:destro... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/vagrant_configs_controller.rb | Ruby | apache-2.0 | 45 | master | 908 | # frozen_string_literal: true
class VagrantConfigsController < ApplicationController
before_action :set_vagrant_config, only: [:edit, :update]
def edit
end
def update
@vagrant_config.update!(vagrant_config_params)
flash[:success] = 'The Vagrant configuration was successfully updated.'
redirect_to... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/application_controller.rb | Ruby | apache-2.0 | 45 | master | 780 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
# Support pagination for scope and array filtering
require 'will_paginate/array'
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception, pr... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/controllers/metric_observations_controller.rb | Ruby | apache-2.0 | 45 | master | 2,667 | # frozen_string_literal: true
# Abstraction for different types of MetricObservations:
# * The implementation detail which MetricObservation (e.g. nominal, ordered) should remain hidden for a client.
# * The concrete implementation is chosen based on the metric_type from the associated MetricDefinition
class MetricObs... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/benchmark_schedules_helper.rb | Ruby | apache-2.0 | 45 | master | 1,777 | # frozen_string_literal: true
module BenchmarkSchedulesHelper
def toggle_benchmark_schedule_link(schedule)
toggle_benchmark_schedule(schedule, activate_class: 'activate-color', deactivate_class: 'deactivate-color')
end
def toggle_benchmark_schedule_btn(schedule)
toggle_benchmark_schedule(schedule, activ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/event_helper.rb | Ruby | apache-2.0 | 45 | master | 375 | # frozen_string_literal: true
module EventHelper
def has_log(event)
event.started_preparing? || event.started_releasing_resources?
end
def previous_event_on_same_day(event)
prev = event.previous
prev.present? && same_day(event.happened_at, prev.happened_at)
end
def previous_event_on_other_day(e... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/metric_definitions_helper.rb | Ruby | apache-2.0 | 45 | master | 430 | # frozen_string_literal: true
module MetricDefinitionsHelper
def confirm_delete_metric_msg(metric)
{ confirm: "This action deletes the <strong>#{metric.name}</strong> metric definition and all its associated observations.".html_safe }
end
def metric_definition_description(metric_definition)
link_to "#{m... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/benchmark_executions_helper.rb | Ruby | apache-2.0 | 45 | master | 4,150 | # frozen_string_literal: true
module BenchmarkExecutionsHelper
def execution_status_label(execution)
if execution.failed?
type = 'danger'
elsif execution.active?
type = 'success'
elsif execution.finished?
type = 'default'
elsif execution.inactive?
type = 'warning'
end
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/application_helper.rb | Ruby | apache-2.0 | 45 | master | 334 | # frozen_string_literal: true
module ApplicationHelper
def content_header(title, subtitle = '')
content_for :content_header do
"<h1>#{title}<small>#{subtitle}</small></h1>".html_safe
end
end
def actives_badge(count)
"<small class='badge badge-total pull-right bg-green'>#{count}</small>".html_s... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/flash_helper.rb | Ruby | apache-2.0 | 45 | master | 678 | # frozen_string_literal: true
module FlashHelper
# FLASH_LEVEL: [ CLASS_TYPE, ICON ]
CLASS_TYPE = 0
ICON = 1
FLASH_MAPPINGS = {
notice: %w(success check),
info: %w(info info),
success: %w(success check),
error: %w(danger warning),
alert: %w(danger warning)
}
def flash_class... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/virtual_machine_instances_helper.rb | Ruby | apache-2.0 | 45 | master | 230 | # frozen_string_literal: true
module VirtualMachineInstancesHelper
def confirm_delete_vm_instance_msg(vm_instance)
{ confirm: 'This action will delete this execution and all its associated metric_observations.' }
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/time_helper.rb | Ruby | apache-2.0 | 45 | master | 319 | # frozen_string_literal: true
module TimeHelper
# NOTE: Keep in mind that the db format does NOT reflect the time zone!
def formatted_time(time, format = :db)
time.present? ? time.to_formatted_s(format) : '-'
end
def same_day(first, second)
first.beginning_of_day == second.beginning_of_day
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/icon_helper.rb | Ruby | apache-2.0 | 45 | master | 934 | # frozen_string_literal: true
module IconHelper
def ion_icon(name, html_class = '')
"<i class='ion ion-#{name} #{html_class}'></i>".html_safe
end
FA_ICON_MAPPINGS = {
abort: 'power-off',
active: 'cog spin',
clone: 'copy',
create: 'plus',
dashboard: 'dashboard',
definition: 'file-text... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/benchmark_definitions_helper.rb | Ruby | apache-2.0 | 45 | master | 1,285 | # frozen_string_literal: true
module BenchmarkDefinitionsHelper
def confirm_delete_benchmark_msg(benchmark_definition)
{ confirm: (render 'benchmark_definitions/confirm_delete', benchmark_definition: benchmark_definition) }
end
def schedule_metric_sidebar(benchmark_definition, benchmark_execution = {})
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/vagrant_configs_helper.rb | Ruby | apache-2.0 | 45 | master | 280 | # frozen_string_literal: true
module VagrantConfigsHelper
def base_file_error?(vagrant_config)
vagrant_config.errors[:base_file].any?
end
def doc_link(name, link, icon = 'github')
link_to "#{name} #{fa_icon(icon)}".html_safe, link, target: '_blank'
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/helpers/status_helper.rb | Ruby | apache-2.0 | 45 | master | 1,380 | # frozen_string_literal: true
module StatusHelper
LINE_BREAK_STRINGS = [
'WAITING FOR',
'FAILED ON',
]
def split_status(status)
line_break_string = LINE_BREAK_STRINGS.find { |line_break_string| status.start_with?(line_break_string) }
line_break_string.present? ? [line_break_string, second_par... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/jobs/prepare_benchmark_execution_job.rb | Ruby | apache-2.0 | 45 | master | 234 | # frozen_string_literal: true
class PrepareBenchmarkExecutionJob < Struct.new(:benchmark_execution_id)
def perform
benchmark_execution = BenchmarkExecution.find(benchmark_execution_id)
benchmark_execution.prepare
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/jobs/start_postprocessing_job.rb | Ruby | apache-2.0 | 45 | master | 241 | # frozen_string_literal: true
class StartPostprocessingJob < Struct.new(:benchmark_execution_id)
def perform
benchmark_execution = BenchmarkExecution.find(benchmark_execution_id)
benchmark_execution.start_postprocessing
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/jobs/reprovision_benchmark_execution_job.rb | Ruby | apache-2.0 | 45 | master | 242 | # frozen_string_literal: true
class ReprovisionBenchmarkExecutionJob < Struct.new(:benchmark_execution_id)
def perform
benchmark_execution = BenchmarkExecution.find(benchmark_execution_id)
benchmark_execution.reprovision
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/jobs/start_benchmark_execution_job.rb | Ruby | apache-2.0 | 45 | master | 240 | # frozen_string_literal: true
class StartBenchmarkExecutionJob < Struct.new(:benchmark_execution_id)
def perform
benchmark_execution = BenchmarkExecution.find(benchmark_execution_id)
benchmark_execution.start_benchmark
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/jobs/release_resources_job.rb | Ruby | apache-2.0 | 45 | master | 235 | # frozen_string_literal: true
class ReleaseResourcesJob < Struct.new(:benchmark_execution_id)
def perform
benchmark_execution = BenchmarkExecution.find(benchmark_execution_id)
benchmark_execution.release_resources
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/benchmark_definition.rb | Ruby | apache-2.0 | 45 | master | 3,673 | # frozen_string_literal: true
require 'securerandom'
class BenchmarkDefinition < ApplicationRecord
extend Enumerize
PROVIDERS = Rails.application.config.supported_providers
enumerize :provider_name, in: PROVIDERS, default: PROVIDERS.first
has_one :benchmark_schedule, dependent: :destroy
has_many :metric_defi... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/vagrantfile_binding.rb | Ruby | apache-2.0 | 45 | master | 601 | # frozen_string_literal: true
class VagrantfileBinding
attr_reader :execution
attr_reader :benchmark_name_sanitized
def initialize(opts)
@benchmark = opts[:benchmark]
@execution = opts[:execution]
@benchmark_name_sanitized = opts[:benchmark_name_sanitized]
end
def benchmark_id
@benchmark.id... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/event.rb | Ruby | apache-2.0 | 45 | master | 3,502 | # frozen_string_literal: true
class Event < ApplicationRecord
default_scope { order(happened_at: :asc) }
scope :happened_before, lambda { |time| where('happened_at < ?', time).reorder(happened_at: :desc) }
scope :happened_after, lambda { |time| where('happened_at > ?', time).reorder(happened_at: :asc) }
belon... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/vagrant_config.rb | Ruby | apache-2.0 | 45 | master | 776 | # frozen_string_literal: true
class VagrantConfig < ActiveRecord::Base
# Single implementation based on: https://stackoverflow.com/a/12463209/6875981
# The "singleton_guard" column is a unique column which must always be set to '0'
# This ensures that only one VagrantConfig row is created
validates_inclusion_o... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/vagrant_driver.rb | Ruby | apache-2.0 | 45 | master | 2,552 | # frozen_string_literal: true
require 'pathname'
# Vagrant commands can be further refactored into its own method and
# generic access can be provided to commands ands its corresponding logs.
class VagrantDriver
include ShellRunner
attr_reader :vagrantfile_path, :vagrant_dir_path
CURRENT_DIR = '.'
PARENT_DIR =... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/benchmark_schedule.rb | Ruby | apache-2.0 | 45 | master | 3,144 | # frozen_string_literal: true
require 'pathname'
require 'fileutils'
require 'erb'
class BenchmarkSchedule < ApplicationRecord
scope :actives, -> { where(active: true) }
DEFAULT_TEMPLATE_PATH = Rails.application.config.benchmark_schedule_template
DEFAULT_SCHEDULE_PATH = Rails.application.config.benchmark_schedul... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/virtual_machine_instance.rb | Ruby | apache-2.0 | 45 | master | 1,153 | # frozen_string_literal: true
class VirtualMachineInstance < ApplicationRecord
belongs_to :benchmark_execution
validates :benchmark_execution, presence: true
has_many :nominal_metric_observations, dependent: :destroy
has_many :ordered_metric_observations, dependent: :destroy
default_scope { order('created_at... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/nominal_metric_observation.rb | Ruby | apache-2.0 | 45 | master | 207 | # frozen_string_literal: true
class NominalMetricObservation < ApplicationRecord
belongs_to :metric_definition
validates :metric_definition_id, presence: true
belongs_to :virtual_machine_instance
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/ordered_metric_observation.rb | Ruby | apache-2.0 | 45 | master | 207 | # frozen_string_literal: true
class OrderedMetricObservation < ApplicationRecord
belongs_to :metric_definition
validates :metric_definition_id, presence: true
belongs_to :virtual_machine_instance
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/metric_definition.rb | Ruby | apache-2.0 | 45 | master | 890 | # frozen_string_literal: true
class MetricDefinition < ApplicationRecord
extend Enumerize
belongs_to :benchmark_definition
has_many :nominal_metric_observations, dependent: :destroy
has_many :ordered_metric_observations, dependent: :destroy
enumerize :scale_type, in: [:nominal, :ordinal, :interval, :ratio]... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/event_status_helper.rb | Ruby | apache-2.0 | 45 | master | 2,428 | # frozen_string_literal: true
module EventStatusHelper
# Traceable (e.g. Execution)
def active?
# Executions without id may just be built from a view (e.g. start execution button) and does not really exist
id.present? && !has_event_with_name?(:finished_releasing_resources) && !has_event_with_name?(:failed_... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/vagrant_file_system.rb | Ruby | apache-2.0 | 45 | master | 2,287 | # frozen_string_literal: true
require 'erb'
require 'fileutils'
class VagrantFileSystem
attr_reader :benchmark_definition, :benchmark_execution
def initialize(benchmark_definition, benchmark_execution)
@benchmark_definition = benchmark_definition
@benchmark_execution = benchmark_execution
end
def pre... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/metric_observation.rb | Ruby | apache-2.0 | 45 | master | 4,728 | # frozen_string_literal: true
require 'forwardable'
class MetricObservation
attr_accessor(:provider_name, :provider_instance_id)
attr_reader(:concrete_metric_observation)
extend TimeHelper
include ActiveModel::Model
extend Forwardable
# Delegate the common methods to the concrete implementation.
def_de... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/user.rb | Ruby | apache-2.0 | 45 | master | 289 | # frozen_string_literal: true
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :registerable, :recoverable, :validatable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable, :timeoutable
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/benchmark_execution.rb | Ruby | apache-2.0 | 45 | master | 6,647 | # frozen_string_literal: true
class BenchmarkExecution < ApplicationRecord
DEFAULT_PROVIDER = Rails.application.config.supported_providers.first
PRIORITY_HIGH = 1
belongs_to :benchmark_definition
validates :benchmark_definition, presence: true
has_many :virtual_machine_instances, dependent: :destroy
has_ma... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/events_as_traceable_extension.rb | Ruby | apache-2.0 | 45 | master | 733 | # frozen_string_literal: true
module EventsAsTraceableExtension
def create_with_name!(name, message = '')
create!(name: name, happened_at: Time.current, message: message)
end
def first_with_name(name)
self.find { |event| same_name(event.name, name) }
end
def last_with_name(name)
self.select { |... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/shell_runner.rb | Ruby | apache-2.0 | 45 | master | 1,119 | # frozen_string_literal: true
module ShellRunner
# Runs a shell command. Sanitizes Rails-related environment variables.
#
# @param cmd [String] shell command to execute
# @param opts [Hash] options hash
# dir: directory wherein the command is executed
# log: file path for logging stdout and stderr
# ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | app/models/vagrant_runner.rb | Ruby | apache-2.0 | 45 | master | 963 | # frozen_string_literal: true
class VagrantRunner
include ShellRunner
attr_reader :vagrant_dir
def initialize(vagrant_dir)
@vagrant_dir = vagrant_dir
end
def start_benchmark
ssh_exec(Rails.application.config.vm_start_runner)
end
def start_postprocessing
ssh_exec(Rails.application.config.vm... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/dynamic_delegator.rb | Ruby | apache-2.0 | 45 | master | 420 | # frozen_string_literal: true
# Source: RailsCast by Ryan Bates; Episode 212 Refactoring & Dynamic Delegator
# http://railscasts.com/episodes/212-refactoring-dynamic-delegator
class DynamicDelegator < BasicObject
def initialize(target)
@target = target
end
def method_missing(*args, &block)
result = @ta... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/user.rake | Ruby | apache-2.0 | 45 | master | 1,306 | # frozen_string_literal: true
namespace :user do
desc 'Create or update (if password has changed) the default user.'
task create_default: :environment do
default_email = Rails.application.config.default_email
default_password = Rails.application.config.default_password
Rake::Task['user:create'].invoke(... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/db.rake | Ruby | apache-2.0 | 45 | master | 6,183 | # frozen_string_literal: true
require 'pg'
namespace :db do
# Fallbacks to Rails.env or production defaults if no arguments are provided
# NOTICE: requires '' in zsh to prevent zsh pattern matching or escaping \[ \]
desc 'Create or update (if password has changed) a PostgreSQL user. Example: `bin/rake \'db... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/fs.rake | Ruby | apache-2.0 | 45 | master | 2,708 | # frozen_string_literal: true
require 'fileutils'
require 'pathname'
# Clean the file system on db:drop for non-production environments.
Rake::Task['db:drop'].enhance do
Rake::Task['fs:clean'].invoke unless Rails.env.production?
end
namespace :fs do
desc 'Dump the file system by compressing the generated files (... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/factory_girl.rake | Ruby | apache-2.0 | 45 | master | 482 | # frozen_string_literal: true
# Linting factories: https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#linting-factories
namespace :factory_bot do
desc 'Verify that all FactoryBot factories are valid'
task lint: :environment do
if Rails.env.test?
begin
DatabaseCleaner.start
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/data.rake | Ruby | apache-2.0 | 45 | master | 649 | # frozen_string_literal: true
namespace :data do
desc 'Backup database and file storage'
task backup: :environment do
Rake::Task['db:dump'].invoke
Rake::Task['fs:dump'].invoke
end
desc 'List database and file storage backups'
task list: :environment do
puts backup_dir
Dir["#{backup_dir}/**"]... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/tasks/cron.rake | Ruby | apache-2.0 | 45 | master | 533 | # frozen_string_literal: true
# NOTE: Make sure that you run these tasks as the right user!
namespace :cron do
desc 'Clear the generated Cron benchmark schedules (user dependent!).'
task clean: :environment do
BenchmarkSchedule.clear_system_crontab
end
desc 'Update the generated Cron benchmark schedules (... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/template.rb | Ruby | apache-2.0 | 45 | master | 1,110 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
#
# will first try and copy the file: config/deploy/#{full_app_name}/#{from}.erb
# to: shared/config/to if the original source path doesn't exist then it will
# search in: config/deploy/shared/#{from}.erb
# This allow... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/substitute_strings.rb | Ruby | apache-2.0 | 45 | master | 495 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
#
# we often want to refer to variables which
# are defined in subsequent stage files. This
# let's us use the {{var}} to represent fetch(:var)
# in strings which are only evaluated at runtime.
def sub_strings(input_... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/logs.rake | Ruby | apache-2.0 | 45 | master | 655 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :log do
# Example: 'cap production log:tail[production]'
task :tail, :file do |task, args|
if args[:file]
on roles(:app) do
execute "tail -f #{shared_path}/log/#{args[:file]}.log"
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/unicorn.rake | Ruby | apache-2.0 | 45 | master | 310 | # frozen_string_literal: true
namespace :unicorn do
# Example: 'cap production unicorn:status'
RUNIT_COMMANDS.each do |task_name|
desc "#{task_name} unicorn"
task task_name do
on roles(:app), in: :sequence do
sudo "sv #{task_name} #{fetch(:application)}"
end
end
end
end |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/user.rake | Ruby | apache-2.0 | 45 | master | 992 | # frozen_string_literal: true
namespace :user do
desc "Change the password for the default user: 'cap production user:change[new_password]'"
task :change, :password, :environment do |task, args|
on primary(:app) do
within current_path do
with rails_env: fetch(:rails_env) do
default_emai... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/nginx.rake | Ruby | apache-2.0 | 45 | master | 350 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :nginx do
%w(start stop restart reload).each do |task_name|
desc "#{task_name} Nginx"
task task_name do
on roles(:app), in: :sequence, wait: 5 do
sudo "/etc/init.d/nginx #{task_name}... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/setup_config.rake | Ruby | apache-2.0 | 45 | master | 1,877 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :deploy do
task :setup_config do
on roles(:app) do
# make the config dir
execute :mkdir, "-p #{shared_path}/config"
full_app_name = fetch(:full_app_name)
# config files to be ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/compile_assets_locally.rake | Ruby | apache-2.0 | 45 | master | 564 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :deploy do
desc 'compiles assets locally then rsyncs'
task :compile_assets_locally do
run_locally do
execute "RAILS_ENV=#{fetch(:rails_env)} bundle exec rake assets:precompile"
end
on ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/run_tests.rake | Ruby | apache-2.0 | 45 | master | 678 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :run_tests do
test_log = 'log/capistrano.test.log'
tests = fetch(:tests)
tests.each do |test|
puts "-->... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/cron.rake | Ruby | apache-2.0 | 45 | master | 1,542 | # frozen_string_literal: true
namespace :cron do
desc 'Clean system crontab.'
task :clean do
# Workaround for failure on initial (i.e. first) deployment since no checkout is present yet.
begin
cron_task('clean')
rescue => e
puts "WARNING: Could not execute 'cron:clean'. Ignore this waring i... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/worker.rake | Ruby | apache-2.0 | 45 | master | 1,018 | # frozen_string_literal: true
namespace :worker do
DEFAULT_WORKER_NUMBER = 1
# Example: restart all workers with 'worker:restart_all'
RUNIT_COMMANDS.each do |command|
task = "#{command}_all"
desc "#{task} delayed_job workers"
task task do
on roles(:app), in: :sequence do
all_workers(co... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/rake.rake | Ruby | apache-2.0 | 45 | master | 348 | # frozen_string_literal: true
DEFAULT_COMMAND = 'about'
desc "Invoke a rake command on the remote app server: 'cap production rake[about]'"
task :rake, :command do |task, args|
on primary(:app) do
within current_path do
with rails_env: fetch(:rails_env) do
rake ( args[:command] || DEFAULT_COMMAND)
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/bundle.rake | Ruby | apache-2.0 | 45 | master | 368 | # frozen_string_literal: true
# Source: http://stackoverflow.com/a/22206605
namespace :bundle do
# Example: Run via "cap production bundle:list"
desc 'List the installed gems'
task :list do
on roles(:app) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle,... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | lib/capistrano/tasks/check_revision.rake | Ruby | apache-2.0 | 45 | master | 649 | # frozen_string_literal: true
# Source: https://github.com/TalkingQuickly/capistrano-3-rails-template
namespace :deploy do
desc "checks whether the currently checkout out revision matches the
remote one we're trying to deploy from"
task :check_revision do
branch = fetch(:branch)
unless `git rev-pa... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/factories.rb | Ruby | apache-2.0 | 45 | master | 3,581 | # frozen_string_literal: true
require 'erb'
require 'ostruct'
FactoryBot.define do
factory :benchmark_definition do
provider_name { 'aws' }
sequence(:name) { |n| "fio-benchmark #{n}" }
running_timeout { 10 }
sequence(:vagrantfile) do |n|
namespace = OpenStruct.new(n: n)
file_dir = File.e... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/rails_helper.rb | Ruby | apache-2.0 | 45 | master | 2,809 | # frozen_string_literal: true
require 'rubygems'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
# Support for deprecated `its` in RSpec 3 discussed in: https://gist.github.com/myronmarston/4503509
require 'rspec/its'
require 'capybara/rspec'
require 'c... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/spec_helper.rb | Ruby | apache-2.0 | 45 | master | 4,858 | # frozen_string_literal: true
require 'simplecov'
require 'simplecov-console'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
# Uncomment for coverage report in console (clutters test output)
# SimpleCov::Formatter::Console,
# Coveralls formatter for reporting test coverage ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/benchmark_schedules_spec.rb | Ruby | apache-2.0 | 45 | master | 3,276 | # frozen_string_literal: true
require 'rails_helper'
feature 'Benchmark schedule' do
given(:user) { create(:user) }
before { sign_in(user) }
feature 'listing schedules' do
given(:active_schedule) { create(:benchmark_schedule, active: true) }
given(:inactive_schedule) { create(:benchmark_schedule, activ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/sign_in_spec.rb | Ruby | apache-2.0 | 45 | master | 585 | # frozen_string_literal: true
require 'rails_helper'
feature 'Sign in' do
given(:user) { create(:user, password: 'valid_pw') }
before { user.save!; visit root_path }
scenario 'with valid password' do
expect(page).to have_field('password')
fill_in 'password', with: user.password
find('button[type="... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/benchmark_definitions_spec.rb | Ruby | apache-2.0 | 45 | master | 6,295 | # frozen_string_literal: true
require 'rails_helper'
feature 'Benchmark definition management' do
given(:user) { create(:user) }
before { sign_in(user) }
feature 'Listing benchmark definitions' do
scenario 'Should show a link to create a new benchmark' do
visit benchmark_definitions_path
expect... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/benchmark_executions_spec.rb | Ruby | apache-2.0 | 45 | master | 999 | # frozen_string_literal: true
require 'rails_helper'
feature 'Benchmark execution' do
given(:user) { create(:user) }
before { sign_in(user) }
feature 'Listing' do
given(:e1) { create(:benchmark_execution) }
given(:e2) { create(:benchmark_execution) }
background do
e1.save!
e2.save!
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/vagrant_configs_spec.rb | Ruby | apache-2.0 | 45 | master | 1,099 | # frozen_string_literal: true
require 'rails_helper'
feature 'Vagrant Configuration' do
given(:user) { create(:user) }
before { sign_in(user) }
feature 'Show' do
scenario 'Should show the base Vagrantfile' do
visit edit_vagrant_config_path
expect(page).to have_content(/Vagrant.configure/)
e... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/features/support/authentication_helpers.rb | Ruby | apache-2.0 | 45 | master | 393 | # frozen_string_literal: true
include Warden::Test::Helpers
Warden.test_mode!
module AuthenticationHelpers
# Does not work with let or given blocks
def create_signed_in_user
user = create(:user)
sign_in(user)
user
end
def sign_in(user)
login_as user, scope: :user
end
def sign_out(user)
... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/string_extension_spec.rb | Ruby | apache-2.0 | 45 | master | 641 | # frozen_string_literal: true
require 'spec_helper'
describe 'String extension' do
describe 'to_bool' do
describe 'with true values' do
true_values = %w(true True t 1)
true_values.each do |true_value|
it "should recognize the true value '#{true_value}'" do
expect(true_value.to_bool... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/vagrant_config_spec.rb | Ruby | apache-2.0 | 45 | master | 676 | # frozen_string_literal: true
require 'rails_helper'
describe VagrantConfig do
let(:vagrant_config) { VagrantConfig.instance }
it 'provides a default Vagrantfile base template' do
expect(vagrant_config.base_file).to match(/Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|/)
end
describe 'Resetting'... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/benchmark_execution_spec.rb | Ruby | apache-2.0 | 45 | master | 4,776 | # frozen_string_literal: true
require 'rails_helper'
describe BenchmarkExecution do
let(:benchmark_definition) { create(:benchmark_definition) }
let(:benchmark_execution) { benchmark_definition.start_execution_async }
subject { benchmark_execution }
it { is_expected.to respond_to(:events) }
it { is_expect... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/benchmark_schedule_spec.rb | Ruby | apache-2.0 | 45 | master | 1,400 | # frozen_string_literal: true
require 'rails_helper'
describe BenchmarkSchedule do
let(:schedule_file) { Rails.application.config.benchmark_schedule }
context 'when schedule is inactive' do
let(:schedule) { create(:benchmark_schedule, active: false) }
before { FileUtils.rm_f(schedule_file) }
describe ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/vagrant_runner_spec.rb | Ruby | apache-2.0 | 45 | master | 643 | # frozen_string_literal: true
require 'spec_helper'
describe VagrantRunner do
let(:vagrant_dir) { '/tmp/vagrant' }
let(:vagrant_runner) { FactoryBot.build(:vagrant_runner, vagrant_dir: vagrant_dir) }
describe '#vagrant_dir' do
it 'should return the vagrant directory' do
expect(vagrant_runner.vagrant_... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/benchmark_definition_spec.rb | Ruby | apache-2.0 | 45 | master | 3,922 | # frozen_string_literal: true
require 'rails_helper'
describe BenchmarkDefinition do
before do
@benchmark_definition = create(:benchmark_definition)
end
subject { @benchmark_definition }
it { is_expected.to respond_to(:name) }
it { is_expected.to respond_to(:vagrantfile) }
it { is_expected.to respon... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/vagrant_file_system_spec.rb | Ruby | apache-2.0 | 45 | master | 2,244 | # frozen_string_literal: true
require 'rails_helper'
describe VagrantFileSystem do
let(:benchmark_definition) { build(:benchmark_definition, id: 7, name: 'bm-with_symbol%and\\no.dot') }
let(:benchmark_execution) { build(:benchmark_execution, benchmark_definition: benchmark_definition, id: 8) }
let(:vagrant_fs) ... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/shell_runner_spec.rb | Ruby | apache-2.0 | 45 | master | 870 | # frozen_string_literal: true
require 'spec_helper'
describe ShellRunner do
let(:runner_instance) { (Class.new { include ShellRunner }).new }
describe '#shell' do
it 'should run a shell command and return its success value' do
expect(runner_instance.shell('true', {})).to be true
expect(runner_inst... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/event_spec.rb | Ruby | apache-2.0 | 45 | master | 363 | # frozen_string_literal: true
require 'rails_helper'
describe Event do
let(:benchmark_execution) { create(:benchmark_execution) }
let(:event) { benchmark_execution.events.create_with_name!(:created) }
subject { event }
it { is_expected.to be_valid }
its(:failed?) { should be_falsey }
its(:status) { shou... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/vagrant_driver_spec.rb | Ruby | apache-2.0 | 45 | master | 954 | # frozen_string_literal: true
require 'rails_helper'
describe VagrantDriver do
let(:vagrant_driver) { build(:vagrant_driver) }
let(:vm) { build(:virtual_machine_instance) }
describe 'detect_vms_with_role' do
before do
@vms = vagrant_driver.detect_vms_with_role('default')
end
it 'should detect... |
github | sealuzh/cloud-workbench | https://github.com/sealuzh/cloud-workbench | spec/models/benchmark_execution_event_spec.rb | Ruby | apache-2.0 | 45 | master | 2,414 | # frozen_string_literal: true
require 'rails_helper'
# include DurationModule
include TimeDiff::Matchers
describe 'Events of benchmark execution' do
let(:execution) { create(:benchmark_execution) }
before { create_event(:created) }
subject { execution }
its(:active?) { should be_truthy }
describe 'duration... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.