Skip to content

Commit

Permalink
[Bherly/Tara] Add tps configurations to log templates
Browse files Browse the repository at this point in the history
  • Loading branch information
pushm0v committed May 7, 2018
1 parent d5797b2 commit 56d32f8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 93 deletions.
5 changes: 4 additions & 1 deletion app/models/log_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ class LogTemplate < ActiveRecord::Base
validates :zookeeper_instances, presence: true, numericality: {greater_than: 0}
validates :kafka_instances, presence: true, numericality: {greater_than: 0}
validates :es_instances, presence: true, numericality: {greater_than: 0}

validates :consul_instances, presence: true, numericality: {greater_than: 0}
validates :yggdrasil_instances, presence: true, numericality: {greater_than: 0}
validates :kibana_instances, presence: true, numericality: {greater_than: 0}

def name_with_tps
"#{name.camelize} (#{tps_limit} trx/sec)"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddTpsConfigurationsToLogTemplates < ActiveRecord::Migration
def change
add_column :log_templates, :consul_instances, :integer, :default => 0
add_column :log_templates, :yggdrasil_instances, :integer, :default => 0
add_column :log_templates, :kibana_instances, :integer, :default => 0
end
end
97 changes: 6 additions & 91 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180413072400) do
ActiveRecord::Schema.define(version: 20180507040330) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -33,104 +33,19 @@
t.string "receiver_end_point"
end

create_table "client_groups", force: :cascade do |t|
t.integer "client_id"
t.integer "user_group_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
end

add_index "client_groups", ["client_id"], name: "index_client_groups_on_client_id", using: :btree
add_index "client_groups", ["deleted_at"], name: "index_client_groups_on_deleted_at", using: :btree
add_index "client_groups", ["user_group_id"], name: "index_client_groups_on_user_group_id", using: :btree

create_table "clients", force: :cascade do |t|
t.string "name"
t.text "description"
t.integer "stream_id"
t.integer "store_id"
t.string "produce_url"
t.string "kibana_host"
t.string "kafka_topics"
t.integer "kafka_topic_partition"
t.string "heartbeat_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "forwarder_id", default: 0, null: false
t.string "application_secret"
t.integer "user_id"
t.datetime "deleted_at"
end

add_index "clients", ["deleted_at"], name: "index_clients_on_deleted_at", using: :btree
add_index "clients", ["user_id"], name: "index_clients_on_user_id", using: :btree

create_table "databags", force: :cascade do |t|
t.string "ip_address"
t.json "data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "tags", default: "", null: false
t.datetime "deleted_at"
end

add_index "databags", ["deleted_at"], name: "index_databags_on_deleted_at", using: :btree

create_table "forwarders", force: :cascade do |t|
t.string "name"
t.string "host"
t.integer "stream_id"
t.integer "store_id"
t.string "kafka_broker_hosts"
t.string "zookeeper_hosts"
t.string "kafka_topics"
t.string "heartbeat_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
end

add_index "forwarders", ["deleted_at"], name: "index_forwarders_on_deleted_at", using: :btree

create_table "log_templates", force: :cascade do |t|
t.string "name"
t.integer "tps_limit"
t.integer "zookeeper_instances"
t.integer "kafka_instances"
t.integer "es_instances"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "consul_instances", default: 0
t.integer "yggdrasil_instances", default: 0
t.integer "kibana_instances", default: 0
end

create_table "stores", force: :cascade do |t|
t.string "name"
t.string "elasticsearch_host"
t.string "kibana_host"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
end

add_index "stores", ["deleted_at"], name: "index_stores_on_deleted_at", using: :btree

create_table "streams", force: :cascade do |t|
t.string "name"
t.string "receiver_host"
t.string "zookeeper_hosts"
t.string "kafka_broker_hosts"
t.string "receiver_heartbeat_url"
t.string "kafka_manager_host"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "kafka_topic_partition", default: 0, null: false
t.integer "databag_id"
t.string "receiver_port"
t.datetime "deleted_at"
end

add_index "streams", ["deleted_at"], name: "index_streams_on_deleted_at", using: :btree

create_table "user_groups", force: :cascade do |t|
t.string "name"
t.integer "created_by"
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/log_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
zookeeper_instances 1
kafka_instances 1
es_instances 1
consul_instances 1
yggdrasil_instances 1
kibana_instances 1
end
end
22 changes: 21 additions & 1 deletion spec/models/log_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,25 @@
expect(template.name_with_tps).to eq('Template1 (1 trx/sec)')
end
end


context 'consul_instances' do
it 'must be presence' do
template = FactoryBot.build(:log_template, consul_instances: nil)
expect(template).to_not be_valid
end
end

context 'yggdrasil_instances' do
it 'must be presence' do
template = FactoryBot.build(:log_template, yggdrasil_instances: nil)
expect(template).to_not be_valid
end
end

context 'kibana_instances' do
it 'must be presence' do
template = FactoryBot.build(:log_template, kibana_instances: nil)
expect(template).to_not be_valid
end
end
end

0 comments on commit 56d32f8

Please sign in to comment.