Exemplo n.º 1
6
      return async(this, function*() {
        var err = yield result.catch((err) => { return err; });
        h.expect(err).to.instanceOf(Error).and.match(regex);

        var data = yield h.docker.findContainer(err.container.Id);
        h.expect(data).to.null;
      });
Exemplo n.º 2
0
 return court.judge(rootFullPath).then(function () {
   var systems = Object.keys(court.systems_suggestions);
   h.expect(systems).to.have.length(3);
   h.expect(systems).to.contains('api');
   h.expect(systems).to.contains('front');
   h.expect(systems).to.contains('postgres');
 });
Exemplo n.º 3
0
 return async(function* () {
   var container = yield system.runDaemon();
   var data      = yield container.inspect();
   h.expect(data).to.have.deep.property('Annotations.azk.sys', system.name);
   h.expect(data).to.have.deep.property('State.ExitCode', 0);
   h.expect(data).to.have.deep.property('State.Running').and.ok;
 });
Exemplo n.º 4
0
 it("should return default docker options", function() {
   h.expect(options).to.have.property("daemon", false);
   h.expect(options).to.have.property("ports").and.empty;
   h.expect(options).to.have.property("working_dir").and.eql(system.workdir);
   h.expect(options).to.have.property("env").and.eql({ ECHO_DATA: "data", FROM_DOT_ENV: "azk is beautiful" });
   h.expect(options).to.have.property("dns").and.eql(net.nameServers());
 });
Exemplo n.º 5
0
    it("should be marked as supporting provisioned", function() {
      h.expect(system).to.have.property("provisioned").and.null;

      var date = new Date();
      system.provisioned = date;
      h.expect(system).to.have.property("provisioned").and.eql(date);
    });
Exemplo n.º 6
0
  it('should load rules when calling court.rule()', function() {
    var node = court.rule('node');
    h.expect(node).to.have.property('type', 'runtime');

    var rails = court.rule('ruby_on_rails');
    h.expect(rails).to.have.property('type', 'framework');
  });
Exemplo n.º 7
0
  it('rules should return all relevant files', function() {
    // Asks rule about which files to lookup
    var relevantFiles = court.relevantsFiles();

    h.expect(relevantFiles).to.include('Gemfile');
    h.expect(relevantFiles).to.include('package.json');
  });
Exemplo n.º 8
0
          return image.inspect().then((image_data) => {
            var options = system.daemonOptions({ image_data });

            h.expect(options).to.deep.have.property("ports.80/tcp").and.eql([{
              HostIp: config('agent:dns:ip')
            }]);
            h.expect(options).to.have.property("ports").and.not.have.property("53/udp");
          });
Exemplo n.º 9
0
      it("should configure network", function() {
        h.expect(info).has.property("nic1", "hostonly");
        h.expect(info).has.property("cableconnected1", true);
        h.expect(info).has.property("hostonlyadapter1").and.match(/vboxnet/);

        h.expect(info).has.property("nic2", "nat");
        h.expect(info).has.property("cableconnected2", true);
      });
Exemplo n.º 10
0
 return async(function* () {
   var exitResult = yield system.runShell({
     command: ["ls -ls; exit"],
     stdout: mocks.stdout, stderr: mocks.stderr
   });
   h.expect(exitResult).to.have.property("code", 0);
   h.expect(outputs).to.have.property("stdout").match(/.*src/);
 });
Exemplo n.º 11
0
  it('should find relevant files on project folder', function() {
    // Asks rule about which files to lookup
    var relevantFiles = court.relevantsFiles();
    var relevantProjectFiles = court._relevantProjectFiles(rootFullPath, relevantFiles);
    h.expect(relevantProjectFiles.length).to.equal(0);

    var relevantProjectSubFiles = court._relevantProjectFiles(path.join(rootFullPath, '*'), relevantFiles);
    h.expect(relevantProjectSubFiles.length).to.equal(2);
  });
Exemplo n.º 12
0
 it("should return a volumes property", function() {
   var system  = manifest.system('mount-test');
   var volumes = system.volumes;
   h.expect(volumes).to.have.property(
     manifest.manifestPath, "/azk/" + system.name
   );
   h.expect(volumes).to.have.property(
     path.resolve(manifest.manifestPath, ".."), "/azk/root"
   );
 });
Exemplo n.º 13
0
  it('should suggest systems for the Azkfile.js template', function() {
    court.judge(rootFullPath);
    var folders = Object.keys(court.systems_suggestions);
    h.expect(folders).to.have.length(3);

    h.expect(folders).to.contains('api');
    h.expect(folders).to.contains('front');
    h.expect(folders).to.contains('postgres');

  });
Exemplo n.º 14
0
 it("should expand envs in properties", function*() {
   var system = manifest.system('example');
   var exitResult = yield system.runShell({
     shell: "./bin/test-app",
     command: ["echo", "${ECHO_DATA}"],
     stdout: mocks.stdout, stderr: mocks.stderr
   });
   h.expect(exitResult).to.have.property("code", 0);
   h.expect(outputs).to.have.property("stdout").match(/-c echo data/);
 });
Exemplo n.º 15
0
      return async(function* () {
        var exitResult = yield system.runShell({
          command: ["exit"],
          remove: true, stdout: mocks.stdout, stderr: mocks.stderr
        });

        h.expect(exitResult).to.have.property("code", 0);
        var container = h.docker.findContainer(exitResult.containerId);
        return h.expect(container).to.eventually.null;
      });
Exemplo n.º 16
0
      return async(this, function* () {
        var code;

        code = yield VM.copyFile(name, __filename, "/tmp/azk/file").progress(progress);
        h.expect(code).to.equal(0);

        code = yield VM.ssh(name, "cat /tmp/azk/file").progress(progress);
        h.expect(code).to.equal(0);
        h.expect(data).to.match(/should\scopy\sfile\sto\svm/);
      });
Exemplo n.º 17
0
      return async(this, function* () {
        // Install vm and get infos
        var info = yield aux_tools.install_vm.apply(this);
        var data = yield aux_tools.netinfo();

        // Check for vmbox networking
        var net  = aux_tools.filter_hostonly(data[0], info.hostonlyadapter1);
        h.expect(net).to.have.property('Name', info.hostonlyadapter1);
        h.expect(net).to.have.property('IPAddress'  , net_opts.gateway);
        h.expect(net).to.have.property('NetworkMask', net_opts.netmask);

        // Networking configure guest ip
        var result, key_base = "/VirtualBox/D2D/eth0";
        result = yield VM.getProperty(opts.name, `${key_base}/address`);
        h.expect(result).to.eql({ Value: net_opts.ip });
        result = yield VM.getProperty(opts.name, `${key_base}/netmask`);
        h.expect(result).to.eql({ Value: net_opts.netmask });
        result = yield VM.getProperty(opts.name, `${key_base}/network`);
        h.expect(result).to.eql({ Value: net_opts.network });

        // Check if dhcp server is disabled
        var VBoxNetworkName = net.VBoxNetworkName;
        h.expect(aux_tools.filter_dhcp(data[1], VBoxNetworkName)).to.empty;

        // Removing vm and network interface
        var events   = [];
        var progress = (event) => events.push(event);
        yield remove.apply(this).progress(progress);
        data = yield aux_tools.netinfo();
        h.expect(aux_tools.filter_hostonly(data[0], info.hostonlyadapter1)).to.empty;
        h.expect(events).to.length(2);
      });
Exemplo n.º 18
0
    it('should git-ref=dev with git-repo argument only', function() {
      var parsed_options = cliRouterCleanParams([
        'azk start git@github.com:azukiapp/azkdemo.git#dev'
      ].join(' '));

      h.expect(parsed_options).to.have.property('git_url',
                                                'git@github.com:azukiapp/azkdemo.git');

      h.expect(parsed_options).to.have.property('git_branch_tag_commit',
                                                'dev');
    });
Exemplo n.º 19
0
    it('should get a full git https url with only user/repo', function() {
      var parsed_options = cliRouterCleanParams([
        'azk start azu-ki-app/azk-demo'
      ].join(' '));

      h.expect(parsed_options).to.have.property('git_url',
                                                'https://github.com/azu-ki-app/azk-demo.git');

      h.expect(parsed_options).to.have.property('git_branch_tag_commit',
                                                'master');
    });
Exemplo n.º 20
0
 return image.inspect().then((image_data) => {
   var options = system.daemonOptions({ image_data });
   h.expect(options).to.have.property("working_dir", "/data");
   h.expect(options).to.have.property("command").and.eql(image_data.Config.Cmd);
   h.expect(options).to.have.deep.property("ports.80/tcp").and.eql([{
     HostIp: config('agent:dns:ip')
   }]);
   h.expect(options).to.have.deep.property("ports.53/udp").and.eql([{
     HostIp: config('agent:dns:ip')
   }]);
 });
Exemplo n.º 21
0
        return async(this, function* () {
          for (var i = 0; i < 3; i++) {
            yield system.runDaemon();
          }
          var instances = yield system.instances({ type: "daemon" });

          h.expect(instances).to.length(3);
          h.expect(instances).to.have.deep.property("[0].Annotations.azk.seq", "1");
          h.expect(instances).to.have.deep.property("[1].Annotations.azk.seq", "2");
          h.expect(instances).to.have.deep.property("[2].Annotations.azk.seq", "3");
        });
Exemplo n.º 22
0
    it('should git-ref=master with --git-ref', function() {
      var parsed_options = cliRouterCleanParams([
        'azk start git@github.com:azukiapp/azkdemo.git',
        '--git-ref master',
      ].join(' '));

      h.expect(parsed_options).to.have.property('git_url',
                                                'git@github.com:azukiapp/azkdemo.git');

      h.expect(parsed_options).to.have.property('git_branch_tag_commit',
                                                'master');
    });
Exemplo n.º 23
0
    it('should prioritize `--git-ref` with both `--git-ref` and `repo#ref`', function() {
      var parsed_options = cliRouterCleanParams([
        'azk start git@github.com:azukiapp/azkdemo.git#master',
        '--git-ref dev'
      ].join(' '));

      h.expect(parsed_options).to.have.property('git_url',
                                                'git@github.com:azukiapp/azkdemo.git');

      h.expect(parsed_options).to.have.property('git_branch_tag_commit',
                                                'dev');
    });
Exemplo n.º 24
0
        return async(this, function* () {
          var result, data = "foo", key = "bar";
          // Set property
          yield VM.setProperty(opts.name, key, data, "TRANSIENT");

          // Get property
          result = yield VM.getProperty(opts.name, key);
          h.expect(result).to.eql({ Value: data });

          // Get a not set
          result = yield VM.getProperty(opts.name, "any_foo_key_not_set");
          h.expect(result).to.eql({});
        });
Exemplo n.º 25
0
    return async(function* () {
      var cmd  = ["/bin/true"];
      var opts = { rm: false, stdout: mocks.stdout };
      var cont = yield h.docker.run(default_img, cmd, opts);
      var data = yield cont.inspect();

      h.expect(data).to.have.deep.property("Annotations.azk.azk" , "test");
      h.expect(data).to.have.deep.property("Annotations.azk.type", "run");
      h.expect(data).to.have.deep.property("Annotations.azk.uid").and.match(/^[0-9a-f]+$/);

      var name = RegExp(namespace + "_type.run_uid.[0-9a-f]+");
      h.expect(data).to.have.property('Name').and.match(name);
    });
Exemplo n.º 26
0
      return async(function* () {
        var command = ["/bin/sh", "-c"];
        var options = { stdout: mocks.stdout, stderr: mocks.stderr };

        var exitResult = yield system.runShell([...command].concat("rm provisioned; ls -l"), options);
        h.expect(exitResult).to.have.property("code", 0);
        yield system.runDaemon();

        yield system.runShell([...command].concat("ls -l"), options);
        h.expect(outputs).to.have.property("stdout").match(/provisioned/);

        h.expect(system).to.have.property("provisioned").and.not.null;
      });
Exemplo n.º 27
0
 it("should return option with stdio maped", function() {
   // Customized options
   var custom = {
     interactive: true,
     stdout: { stdout: true, isTTY : true },
     stderr: { stderr: true },
     stdin : { stdin : true },
   };
   var options = system.shellOptions(custom);
   h.expect(options).to.have.property("tty").and.ok;
   h.expect(options).to.have.deep.property("stdout.stdout").and.ok;
   h.expect(options).to.have.deep.property("stderr.stderr").and.ok;
   h.expect(options).to.have.deep.property("stdin.stdin").and.ok;
 });
Exemplo n.º 28
0
      it('should has correct properties', function() {
        // main properties
        h.expect(system).to.have.property('name', 'railsPostgres');
        h.expect(system).to.have.deep.property('image.repository', 'azukiapp/ruby');
        h.expect(system).to.have.deep.property('image.tag', 'latest');

        // __options
        h.expect(system).to.have.deep.property('options.depends').and.to.eql(['postgres']);
        h.expect(system).to.have.deep.property('options.shell', '/bin/bash');
        h.expect(system).to.have.deep.property('options.wait', 20);

        var workdir = path.join('/azk', rootFolderBasename, 'railsPostgres');
        h.expect(system).to.have.deep.property('options.workdir', workdir);

        var expectedMounts = {};
        var folderSystem = `${rootFolderBasename}/${systemName}`;
        // /azk/azk-test-60957fmnsb4/railsPostgres
        expectedMounts[path.join('/azk', folderSystem)] = {
          type: 'sync', value: `./${systemName}`, options: {}
        };
        expectedMounts[path.join('/azk', folderSystem, '.bundle')] = {
          type: 'path', value: `./${systemName}/.bundle`, options: {}
        };
        expectedMounts[path.join('/azk', folderSystem, 'log')] = {
          type: 'path', value: `./${systemName}/log`, options: {}
        };
        expectedMounts[path.join('/azk', folderSystem, 'tmp')] = {
          type: 'persistent', value: `./${systemName}/tmp`, options: {}
        };
        expectedMounts['/azk/bundler'] = { type: 'persistent', value: `./${systemName}/bundler`, options: {} };

        h.expect(system).to.have.deep.property('options.mounts').and.to.eql(expectedMounts);
      });
Exemplo n.º 29
0
      it("should map system ports to docker ports", function() {
        var system  = manifest.system('ports-test');
        var options = system.daemonOptions();

        h.expect(options).to.deep.have.property("ports.80/tcp").and.eql([{
          HostIp: config('agent:dns:ip')
        }]);
        h.expect(options).to.deep.have.property("ports.53/udp").and.eql([{
          HostIp: config('agent:dns:ip')
        }]);
        h.expect(options).to.deep.have.property("ports.443/tcp").and.eql([{
          HostIp: config('agent:dns:ip'), HostPort: "443"
        }]);
      });
Exemplo n.º 30
0
    it("should generate with a valid format", function() {
      var extra = _.merge({}, default_data, {
        systems: {
           front: { envs: { "F-O_O": "BAR"}, scalable: { default: 3}}
        }
      });

      var manifest = generate_manifest(dir, extra);
      var data = fs.readFileSync(manifest.file).toString();

      h.expect(data).to.match(/^\s{2}db: {$/m);
      h.expect(data).to.match(/^\s{6}RACK_ENV: "dev",$/m);
      h.expect(data).to.match(/^\s{6}'F-O_O': "BAR",$/m);
    });