Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start accepting data for benchmark environment #13

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def create
end
end

rep = Report.create report: JSON.generate(ary)
rep = Report.create report: JSON.generate(ary),
ruby: input["ruby"],
os: input["os"],
arch: input["arch"]

options = input["options"] || {}

Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20231006184214_add_attributes_to_reports.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddAttributesToReports < ActiveRecord::Migration[7.0]
def change
add_column :reports, :ruby, :string
add_column :reports, :os, :string
add_column :reports, :arch, :string
end
end
14 changes: 8 additions & 6 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2016_04_13_035657) do

ActiveRecord::Schema[7.0].define(version: 2023_10_06_184214) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "reports", id: :serial, force: :cascade do |t|
t.text "report"
t.boolean "compare"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.string "ruby"
t.string "os"
t.string "arch"
end

end
34 changes: 32 additions & 2 deletions test/controllers/reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ReportsControllerTest < ActionController::TestCase
}]
}
DATA

post :create, body: data

assert_equal "400", @response.code
Expand All @@ -79,10 +79,40 @@ class ReportsControllerTest < ActionController::TestCase
}]
}
DATA

post :create, body: data

assert_equal "400", @response.code
end

test "environment variables are sent, processed, and saved" do
data = {
"ruby" => "3.2.1",
"os" => "Linux",
"arch" => "x86_64",
"entries" => [
{
"name" => "test",
"ips" => 10.1,
"central_tendency" => 10.1,
"error" => 23666,
"stddev" => 0.3,
"microseconds" => 3322,
"iterations" => 221,
"cycles" => 16
}
]
}

post :create, body: data.to_json

require "byebug"; byebug
etagwerker marked this conversation as resolved.
Show resolved Hide resolved
rep = JSON.parse @response.body

report = Report.find_from_short_id rep["id"]

assert_equal "3.2.1", report.ruby
assert_equal "Linux", report.os
assert_equal "x86_64", report.arch
end
end