Question

I am wondering why trying to run the following test suite fails when I try to delete the table I have stored entities in. The error I get is the following

1) Azure Storage cloud storage operations "after all" hook: Error: The specified resource does not exist. RequestId:3745d709-fa5e-4a2b-b517-89edad3efdd2 Time:2013-12-03T22:26:39.5532356Z

If I comment out the actual insertion of data it fails every other time, and if I try to do the insertion of data it fails every time with an additional "The table specified does not exist.".

For the first case this seems to indicate that there is some kind of delay in the table creation, so in every other test it is successful, and for the second case it seems to indicate that even though my callbacks are being called after table creation, the table(s) still aren't ready for data insertion.

The test suite and associated code looks like this:

describe('cloud storage operations', function () {
    var storage;

    before(function (done) {
        this.timeout(5000);
        storage = AzureStorage.usingTable('TEST', done);
    });

    after(function (done) {
        storage.deleteTable(done);
    });

    it('should store without trouble', function (done) {
        storage.save(factory.createChangeSet()).then(done, done);
    });
});

... // snipped from azure.js

  var AzureStorage = function (storageClient, tableName, callback) {
    assert(storageClient && tableName && partitionKey, "Missing parameters");

    this.storageClient = storageClient;
    this.tableName = tableName;

    var defaultCallback = function (err) { if (err) { throw error; } };

    this.storageClient.createTableIfNotExists(this.tableName, function () {
      callback();
    } || defaultCallback);
  };

  AzureStorage.usingTable = function (tableName, callback) {
    return new AzureStorage(
      azure.createTableService(accountName, accountKey)
      , tableName
      , callback
    );
  };

AzureStorage.prototype.deleteTable = function (callback) {
    this.storageClient.deleteTable(this.tableName, callback);
};
Was it helpful?

Solution

I've hit this using the c# library as well but I'm pretty sure the error message indicated the table could not be created because an operation was still in process for a table of the same name. Thinking of the backend supporting storage, it makes sense that it would not be instant. The table needs to be removed from the 3 local replicas as well as the replicas in the paired data center.

With that kind of async operation, it is going to be challenging to build up an tear them down fast enough for tests.

A workaround might be to increment a value appended to the "TEST" table name that would be unique to that test run.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top