18:03 Today: adding tests for incremental price calculation. Last Monday I did identify all the places where I need to change my code, so let’s dive right back into.
So for the following price table:
First 1 GB of data transferred out per month is free; thereafter:
- $0.170 per GB – first 10 TB / month data transfer out
- $0.130 per GB – next 40 TB / month data transfer out
- $0.110 per GB – next 100 TB / month data transfer out
- $0.100 per GB – data transfer out / month over 150 TB
I wrote the following test that ensure that the proper price is used when the cumulated data reaches the next level:
publicfunction testRdsPricing():void {
var pricing:BasePricing = new RdsPricing();
var context:Object = {factor:pricing.getContext().factor, pricing:pricing.getContext().pricing};
var price:Number = pricing.calculatePrice(null, ‘DataTransfer-Out-Bytes’, 1*BasePricing.GIGA, 0, context);
assertEquals(0.17, price);
price = pricing.calculatePrice(null, ‘DataTransfer-Out-Bytes’, 2*BasePricing.GIGA, 0, context);
assertEquals(0.34, price);
price = pricing.calculatePrice(null, ‘DataTransfer-Out-Bytes’, 1*BasePricing.GIGA, BasePricing.TB40, context);
assertEquals(0.13, price);
price = pricing.calculatePrice(null, ‘DataTransfer-Out-Bytes’, 1*BasePricing.GIGA, BasePricing.TB100, context);
assertEquals(0.11, price);
price = pricing.calculatePrice(null, ‘DataTransfer-Out-Bytes’, 1*BasePricing.GIGA, BasePricing.TB100+1, context);
assertEquals(0.10, price);
}
The parameters in bold is the cumulated usage value the price aggregator will pass to the calculatePrice method and is used to determine the price bracket.
So the test seems to produce the correct price, so apparently I an assume that I’m done with the increment price calculation. If only I had some larger usage logs. There are a few more scenarios that I need to test, also while running the application the Simple Db pricing is calculated wrong. So, I’ve added another test and just found out a small bug in my price definition structure. The “TimedStorage-ByteHrs” was calculated wrong. Amazon has the following example of how to calculate this usage:
Conversion to Total GB-Months: 1,481,763,717,120 Byte-Hours x (1 GB / 1,073,741,824 bytes) x (1 month / 744 hours) = 1.85 GB-Months
20:39 I was a little more involved after all as the usage type units where expressed in GB and the price structure in chunks of TB, so I needed to add a new conversion factor. So I’m getting closer to the correct calculation, but just realized that I need to perform the same exercise I did last week with EC2 with SimpleDb as their pricing structure also defines different pricing on a per zone basis. Ah, the joy of reverse engineering how Amazon calculate it prices…I didn’t think it would take me that long. But that’s enough for today, let’s play a little with other parts of the application.
Here is a first shot at the logo…before giving to my designer. The idea is to somewhat to remind the cubes used in the Amazon Web Services logo but in the format of a chart….Usually my designer has awesome ideas, so let’s see what he comes up with once I’ll bring him on board. For now here is the logo:

21:00 Time to sign out. Next time I’ll need to add price history, especially since the recent price change.