Permalink
Browse files

Tests: Hastur-units was failing because of top-level constant name co…

…llisions. Rename constants.
  • Loading branch information...
1 parent 3da0ce0 commit 3ae2070945b7d14497511ec3e50053de7940e355 Noah Gibbs committed Jan 2, 2013
Showing with 19 additions and 19 deletions.
  1. +19 −19 test/units/retrieval_test.rb
@@ -8,8 +8,8 @@
require "hastur-server/api/cass_java_client"
# Timestamp in seconds
-NOWISH_TIMESTAMP = 1330000400000000
-PACKED_NOWISH = [ NOWISH_TIMESTAMP ].pack("Q>")
+NOW_TS = 1330000400000000
+PACKED_NOW_TS = [ NOW_TS ].pack("Q>")
# Timestamps in microseconds, rounded down to various sizes.
ROW_5MIN_TS = 1329858600000000
@@ -29,7 +29,7 @@ def app
::Hastur::API::CassandraJavaClient.stubs(:new).with([]).returns(@cass_client)
@cass_client.stubs(:status_check)
- Hastur.stubs(:timestamp).returns(NOWISH_TIMESTAMP)
+ Hastur.stubs(:timestamp).returns(NOW_TS)
end
should "raise no error on /statusz" do
@@ -42,20 +42,20 @@ def app
out_hash = {
A1UUID => {
"bobs.gauge" => {
- NOWISH_TIMESTAMP => 37
+ NOW_TS => 37
}
}
}
Hastur::Cassandra.expects(:get).with(@cass_client, [A1UUID], ["gauge"],
- NOWISH_TIMESTAMP - 1, NOWISH_TIMESTAMP, {
+ NOW_TS - 1, NOW_TS, {
:name => "bobs.gauge",
:value_only => true,
- :request_ts => NOWISH_TIMESTAMP}).returns(out_hash)
+ :request_ts => NOW_TS}).returns(out_hash)
result = get "/v2/query?type=gauge&ago=1&uuid=#{A1UUID}&name=bobs.gauge&kind=value"
hash = MultiJson.load(result.body)
- assert_equal 37, hash[A1UUID]["bobs.gauge"][NOWISH_TIMESTAMP.to_s]
+ assert_equal 37, hash[A1UUID]["bobs.gauge"][NOW_TS.to_s]
end
end
@@ -73,7 +73,7 @@ def app
should "do lookup for fully-specified query" do
Hastur::Cassandra.expects(:lookup_label_uuids).with(@cass_client, { "foo" => "bar" },
- NOWISH_TIMESTAMP - 1, NOWISH_TIMESTAMP).returns({
+ NOW_TS - 1, NOW_TS).returns({
"foo" => { "bar" => [ A1UUID ],
"barble" => [ A2UUID ] }, # "Bad" value to filter out
})
@@ -82,8 +82,8 @@ def app
# would mean that the label UUID index and label stat name index disagreed with each other.
Hastur::Cassandra.expects(:lookup_label_stat_names).with(@cass_client, [A1UUID],
{ "foo" => "bar", "baz" => "*" },
- NOWISH_TIMESTAMP - 1,
- NOWISH_TIMESTAMP).returns({
+ NOW_TS - 1,
+ NOW_TS).returns({
"foo" => { "bar" => { "gauge" => { "bobs.gauge" => [A1UUID,A2UUID], # With wrong UUID
"sams.gauge" => [A1UUID] }, # Wrong stat name
"counter" => { "bobs.gauge" => [A1UUID] } }, # Wrong type
@@ -93,22 +93,22 @@ def app
Hastur::Cassandra.expects(:lookup_label_timestamps).with(@cass_client, {
"foo" => { "bar" => { "gauge" => { "bobs.gauge" => [A1UUID] } } },
"baz" => { "zob" => { "gauge" => { "bobs.gauge" => [A1UUID] } } }, # "Must not"
- }, ["baz"], NOWISH_TIMESTAMP - 1, NOWISH_TIMESTAMP).returns({
+ }, ["baz"], NOW_TS - 1, NOW_TS).returns({
"gauge" => {
- "#{A1UUID}-#{ROW_HOUR_TS}" => [ "bobs.gauge-#{PACKED_NOWISH}" ],
+ "#{A1UUID}-#{ROW_HOUR_TS}" => [ "bobs.gauge-#{PACKED_NOW_TS}" ],
}
})
Hastur::Cassandra.expects(:query_cassandra_by_type_rows_cols).with(@cass_client, "gauge", "value",
- { "#{A1UUID}-#{ROW_HOUR_TS}" => [ "bobs.gauge-#{PACKED_NOWISH}" ] },
- { :request_ts => NOWISH_TIMESTAMP, :value_only => true }).returns(
- [ ["#{A1UUID}-#{ROW_HOUR_TS}", "bobs.gauge-#{PACKED_NOWISH}", 37] ])
+ { "#{A1UUID}-#{ROW_HOUR_TS}" => [ "bobs.gauge-#{PACKED_NOW_TS}" ] },
+ { :request_ts => NOW_TS, :value_only => true }).returns(
+ [ ["#{A1UUID}-#{ROW_HOUR_TS}", "bobs.gauge-#{PACKED_NOW_TS}", 37] ])
- final_output = { A1UUID => { "bobs.gauge" => { NOWISH_TIMESTAMP => 37 } } }
+ final_output = { A1UUID => { "bobs.gauge" => { NOW_TS => 37 } } }
Hastur::Cassandra.expects(:convert_list_to_hastur_series).with(
- [ ["#{A1UUID}-#{ROW_HOUR_TS}", "bobs.gauge-#{PACKED_NOWISH}", 37] ], {},
- NOWISH_TIMESTAMP - 1, NOWISH_TIMESTAMP,
- { :request_ts => NOWISH_TIMESTAMP, :value_only => true }).returns(final_output)
+ [ ["#{A1UUID}-#{ROW_HOUR_TS}", "bobs.gauge-#{PACKED_NOW_TS}", 37] ], {},
+ NOW_TS - 1, NOW_TS,
+ { :request_ts => NOW_TS, :value_only => true }).returns(final_output)
result = get "/v2/query?type=gauge&ago=1&uuid=#{A1UUID}&name=bobs.gauge&kind=value&label=foo:bar,!baz"
assert_equal MultiJson.dump(final_output, :pretty => true), result.body.strip

0 comments on commit 3ae2070

Please sign in to comment.