~bcsaller/juju-gui/bundlesOnIE

« back to all changes in this revision

Viewing changes to test/test_sandbox_go.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:
277
277
          {llama: 'pajama'},
278
278
          null,
279
279
          1,
 
280
          null,
 
281
          callback);
 
282
    });
 
283
 
 
284
    it('can deploy with constraints', function(done) {
 
285
      var constraints = {
 
286
        'cpu-cores': 1,
 
287
        'cpu-power': 0,
 
288
        'mem': '512M',
 
289
        'arch': 'i386'
 
290
      };
 
291
 
 
292
      env.connect();
 
293
      // We begin logged in.  See utils.makeFakeBackend.
 
294
      var callback = function(result) {
 
295
        var service = state.db.services.getById('kumquat');
 
296
        assert.deepEqual(service.get('constraints'), constraints);
 
297
        done();
 
298
      };
 
299
      env.deploy(
 
300
          'cs:precise/wordpress-15',
 
301
          'kumquat',
 
302
          {llama: 'pajama'},
 
303
          null,
 
304
          1,
 
305
          constraints,
280
306
          callback);
281
307
    });
282
308
 
288
314
            result.err, 'A service with this name already exists.');
289
315
        done();
290
316
      };
291
 
      env.deploy('cs:precise/wordpress-15', undefined, undefined, undefined, 1,
292
 
          callback);
 
317
      env.deploy('cs:precise/wordpress-15', undefined, undefined, undefined,
 
318
                 1, null, callback);
293
319
    });
294
320
 
295
321
    it('can destroy a service', function(done) {
609
635
          {llama: 'pajama'},
610
636
          null,
611
637
          1,
 
638
          null,
612
639
          localCb);
613
640
    }
614
641
 
661
688
          {llama: 'pajama'},
662
689
          null,
663
690
          1,
 
691
          null,
664
692
          localCb);
665
693
    }
666
694
 
904
932
 
905
933
    it('can add a relation (integration)', function(done) {
906
934
      env.connect();
907
 
      env.deploy('cs:precise/wordpress-15', null, null, null, 1, function() {
908
 
        env.deploy('cs:precise/mysql-26', null, null, null, 1, function() {
909
 
          var endpointA = ['wordpress', {name: 'db', role: 'client'}],
910
 
              endpointB = ['mysql', {name: 'db', role: 'server'}];
911
 
          env.add_relation(endpointA, endpointB, function(recData) {
912
 
            assert.equal(recData.err, undefined);
913
 
            assert.equal(recData.endpoint_a, 'wordpress:db');
914
 
            assert.equal(recData.endpoint_b, 'mysql:db');
915
 
            assert.isObject(recData.result);
916
 
            done();
917
 
          });
918
 
        });
919
 
      });
 
935
      env.deploy(
 
936
          'cs:precise/wordpress-15', null, null, null, 1, null, function() {
 
937
            env.deploy(
 
938
                'cs:precise/mysql-26', null, null, null, 1, null, function() {
 
939
                  var endpointA = ['wordpress', {name: 'db', role: 'client'}],
 
940
                      endpointB = ['mysql', {name: 'db', role: 'server'}];
 
941
                  env.add_relation(endpointA, endpointB, function(recData) {
 
942
                    assert.equal(recData.err, undefined);
 
943
                    assert.equal(recData.endpoint_a, 'wordpress:db');
 
944
                    assert.equal(recData.endpoint_b, 'mysql:db');
 
945
                    assert.isObject(recData.result);
 
946
                    done();
 
947
                  });
 
948
                }
 
949
            );
 
950
          }
 
951
      );
920
952
    });
921
953
 
922
954
    it('is able to add a relation with a subordinate service', function(done) {
1020
1052
 
1021
1053
    it('can remove a relation(integration)', function(done) {
1022
1054
      env.connect();
1023
 
      env.deploy('cs:precise/wordpress-15', null, null, null, 1, function() {
1024
 
        env.deploy('cs:precise/mysql-26', null, null, null, 1, function() {
1025
 
          var endpointA = ['wordpress', {name: 'db', role: 'client'}],
1026
 
              endpointB = ['mysql', {name: 'db', role: 'server'}];
1027
 
          env.add_relation(endpointA, endpointB, function() {
1028
 
            env.remove_relation(endpointA, endpointB, function(recData) {
1029
 
              assert.equal(recData.err, undefined);
1030
 
              assert.equal(recData.endpoint_a, 'wordpress:db');
1031
 
              assert.equal(recData.endpoint_b, 'mysql:db');
1032
 
              done();
1033
 
            });
1034
 
          });
1035
 
        });
1036
 
      });
 
1055
      env.deploy(
 
1056
          'cs:precise/wordpress-15', null, null, null, 1, null, function() {
 
1057
            env.deploy(
 
1058
                'cs:precise/mysql-26', null, null, null, 1, null, function() {
 
1059
                  var endpointA = ['wordpress', {name: 'db', role: 'client'}],
 
1060
                      endpointB = ['mysql', {name: 'db', role: 'server'}];
 
1061
                  env.add_relation(endpointA, endpointB, function() {
 
1062
                    env.remove_relation(
 
1063
                        endpointA, endpointB, function(recData) {
 
1064
                          assert.equal(recData.err, undefined);
 
1065
                          assert.equal(recData.endpoint_a, 'wordpress:db');
 
1066
                          assert.equal(recData.endpoint_b, 'mysql:db');
 
1067
                          done();
 
1068
                        }
 
1069
                    );
 
1070
                  });
 
1071
                }
 
1072
            );
 
1073
          }
 
1074
      );
1037
1075
    });
1038
1076
 
1039
1077
  });