Ensure the test data sample has correct signature

Set the timestamp to iso format and make sure the test data samples
generated by scripts under tools directory have the correct signature.

Change-Id: I1520450ae4e82459b73cc411a698a6faa91a40e0
Closes-Bug: #1499651
This commit is contained in:
Lianhao Lu 2015-09-25 17:12:16 +08:00
parent b4a704af0d
commit b5a49e79e3
2 changed files with 7 additions and 1 deletions

View File

@ -78,7 +78,7 @@ def make_test_data(name, meter_type, unit, volume, random_min,
user_id=user_id,
project_id=project_id,
resource_id=resource_id,
timestamp=timestamp,
timestamp=timestamp.isoformat(),
resource_metadata=resource_metadata,
source=source,
)

View File

@ -27,11 +27,13 @@ import random
import uuid
import make_test_data
from oslo_config import cfg
from oslo_context import context
import oslo_messaging
from six import moves
from ceilometer import messaging
from ceilometer.publisher import utils
from ceilometer import service
@ -79,6 +81,10 @@ def generate_data(send_batch, make_data_args, samples_count,
resource = resources_list[random.randint(0, len(resources_list) - 1)]
resource_samples[resource] += 1
sample['resource_id'] = resource
# need to recalculate signature because of the resource_id change
sig = utils.compute_signature(sample,
cfg.CONF.publisher.telemetry_secret)
sample['message_signature'] = sig
batch.append(sample)
if len(batch) == batch_size:
send_batch(topic, batch)