~bcsaller/juju-gui/bundlesOnIE

« back to all changes in this revision

Viewing changes to test/test_sandbox_python.js

  • Committer: Rick Harding
  • Author(s): Richard Harding
  • Date: 2013-08-23 14:37:48 UTC
  • mfrom: (969.1.12 deploy-constraints)
  • Revision ID: rick.harding@canonical.com-20130823143748-lwkyt9cq1uzd3b2f
Add support for providing constraints on deploy.

- The deploy methods for both environments assume constraints is an empty
object.
- This adds support for the constraints on both go/python environments.
- For the go environment we have to map the names of the constraints from the
ones provided to the user to the Go Caps names required.
- Updates fakebackend and sandboxes for the changes accepting constraints as
well.
- This required adding another argument to env.deploy() and a bunch of adding
a 'null' constraints argument to those calls. This, of course, led to lint'ing
needing to kick in and resize the long lines.

R=jeff.pihach, matthew.scott
CC=
https://codereview.appspot.com/13084045

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
            {llama: 'pajama'},
155
155
            null,
156
156
            1,
 
157
            null,
157
158
            localCb);
158
159
      });
159
160
      env.connect();
209
210
            {llama: 'pajama'},
210
211
            null,
211
212
            1,
 
213
            null,
212
214
            localCb);
213
215
      });
214
216
      env.connect();
383
385
            {llama: 'pajama'},
384
386
            null,
385
387
            1,
 
388
            null,
386
389
            callback);
387
390
      });
388
391
      env.connect();
405
408
            undefined,
406
409
            undefined,
407
410
            1,
 
411
            null,
408
412
            callback);
409
413
      });
410
414
      env.connect();
411
415
    });
412
416
 
 
417
    it('can deploy with constraints', function(done) {
 
418
      var constraints = {
 
419
        'cpu': 1,
 
420
        'mem': '512M',
 
421
        'arch': 'i386'
 
422
      };
 
423
      var data = {
 
424
        op: 'deploy',
 
425
        charm_url: 'cs:precise/wordpress-15',
 
426
        service_name: 'kumquat',
 
427
        config_raw: 'funny: business',
 
428
        constraints: constraints,
 
429
        num_units: 2,
 
430
        request_id: 42
 
431
      };
 
432
      client.onmessage = function(received) {
 
433
        // First message is the provider type and default series.  We ignore
 
434
        // it, and prepare for the next one, which will be the reply to our
 
435
        // deployment.
 
436
        client.onmessage = function(received) {
 
437
          var service = state.db.services.getById('kumquat');
 
438
          assert.deepEqual(service.get('constraints'), {
 
439
            'cpu': 1,
 
440
            'mem': '512M',
 
441
            'arch': 'i386'
 
442
          });
 
443
          done();
 
444
        };
 
445
        client.send(Y.JSON.stringify(data));
 
446
      };
 
447
      client.open();
 
448
    });
 
449
 
413
450
    it('can send a delta stream of changes.', function(done) {
414
451
      // Create a service with the name "wordpress".
415
452
      // The charm store is synchronous in tests, so we don't need a real
1032
1069
            undefined,
1033
1070
            undefined,
1034
1071
            1,
 
1072
            null,
1035
1073
            addRelation);
1036
1074
      });
1037
1075
    });
1138
1176
          done();
1139
1177
        }
1140
1178
        env.deploy(
1141
 
            'cs:precise/wordpress-15', 'kumquat', {llama: 'pajama'}, null, 1,
1142
 
            function() {
1143
 
              env.deploy('cs:precise/mysql-26', null, null, null, 1,
 
1179
            'cs:precise/wordpress-15', 'kumquat',
 
1180
            {llama: 'pajama'}, null, 1, null, function() {
 
1181
              env.deploy('cs:precise/mysql-26', null, null, null, 1, null,
1144
1182
                  function() {
1145
1183
                    env.add_relation(endpoints[0], endpoints[1], function() {
1146
1184
                      env.remove_relation(endpoints[0], endpoints[1], localCb);