Commit 120844ba4f5f428bb78250a665d65f9f363e9a13

Authored by Carlos Vieira
1 parent fd0af941
Exists in master

Modificação do docker-compose e do rancher a pedido da DTI

Vagrantfile
... ... @@ -4,7 +4,7 @@ Vagrant.require_version ">= 1.5.0"
4 4 VAGRANTFILE_API_VERSION = '2'
5 5  
6 6 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7   - config.vm.box = 'ubuntu/trusty64'
  7 + config.vm.box = 'ubuntu/xenial64'
8 8 config.vm.provision :shell, path: 'provision_root.sh'
9 9 config.vm.provision :shell, path: 'provision.sh', privileged: false
10 10 config.vm.network :forwarded_port, guest: 5000, host: 5000
... ...
app/templates/exemplo.html
... ... @@ -6,7 +6,7 @@
6 6 <meta property="creator.productor" content="http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981"/>
7 7 <title>Barra Brasil</title>
8 8 <!--Adicionado para fazer os testes via mocha/chai-jq/chai/zombie -->
9   -<script type="text/javascript" src="jquery.js"></script>
  9 +<script type="text/javascript" src="static/jquery.js"></script>
10 10 <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
11 11  
12 12 <script type="text/javascript">
... ...
build.sh
... ... @@ -29,6 +29,7 @@ then
29 29 cp templates/$profile/barra-brasil-es.js ../docker/public_html/barra.js.es #Copiando enquanto a barra é estática.
30 30 cp templates/exemplo.html ../docker/public_html/index.html #Copiando enquanto a barra é estática.
31 31 cp static/opensans-bold.woff ../docker/public_html/static/ #Copiando enquanto a barra é estática.
  32 + cp static/jquery-2.1.3.min.js ../docker/public_html/jquery.js #Copiando enquanto a barra é estática.
32 33 echo "Copiado"
33 34 else
34 35 echo "Erro. O profile '$profile' não existe."
... ...
docker/Dockerfile
... ... @@ -2,7 +2,7 @@ FROM httpd:2.4
2 2  
3 3 COPY ./conf/httpd.conf /usr/local/apache2/conf/httpd.conf
4 4  
5   -ADD public_html /usr/local/apache2/htdocs
  5 +ADD ./public_html /usr/local/apache2/htdocs
6 6  
7 7 EXPOSE 80
8 8  
... ...
docker/docker-compose.yml
1   -web:
2   - image: govbr/barra.govbr
3   - ports:
4   - - "80:80"
  1 +certificado-barrabrasil:
  2 + ports:
  3 + - 443:80
  4 + labels:
  5 + io.rancher.loadbalancer.ssl.ports: '443'
  6 + tty: true
  7 + image: rancher/load-balancer-service
  8 + links:
  9 + - web:web
  10 + stdin_open: true
  11 +web:
  12 + ports:
  13 + - 80:80/tcp
  14 + tty: true
  15 + image: hub.docker.planejamento.gov.br/barra-brasil:2.1.21
  16 + stdin_open: true
... ...
docker/public_html/index.html
... ... @@ -6,7 +6,7 @@
6 6 <meta property="creator.productor" content="http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981"/>
7 7 <title>Barra Brasil</title>
8 8 <!--Adicionado para fazer os testes via mocha/chai-jq/chai/zombie -->
9   -<script type="text/javascript" src="jquery.js"></script>
  9 +<script type="text/javascript" src="static/jquery.js"></script>
10 10 <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
11 11  
12 12 <script type="text/javascript">
... ...
docker/rancher-compose.yml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +certificado-barrabrasil:
  2 + scale: 1
  3 + load_balancer_config:
  4 + haproxy_config: {}
  5 + default_cert: barra.brasil
  6 + health_check:
  7 + port: 42
  8 + interval: 2000
  9 + unhealthy_threshold: 3
  10 + healthy_threshold: 2
  11 + response_timeout: 2000
  12 +web:
  13 + scale: 1
... ...
makefile
... ... @@ -21,7 +21,10 @@ testReport:
21 21 npm run testReport
22 22  
23 23 teste:
  24 + docker-compose -f docker/docker-compose.yml up -d
24 25 npm run test
  26 + docker rm -f docker_web_1
  27 + docker rmi -f docker_web
25 28  
26 29  
27 30  
... ...
package.json
... ... @@ -6,12 +6,10 @@
6 6 "coffee-script": "1.12.3",
7 7 "coffeescript-concat": "1.0.14",
8 8 "uglifyjs": "2.4.10",
9   -"express": "4.14.1",
10 9 "chai": "3.5.0",
11 10 "chai-jq": "0.0.9",
12 11 "mocha": "3.2.0",
13   -"zombie": "5.0.5",
14   -"ejs": "2.5.5"
  12 +"zombie": "5.0.5"
15 13 },
16 14 "optionalDependencies": {},
17 15 "scripts": {
... ...
provision.sh
... ... @@ -2,22 +2,22 @@
2 2 set -e -x -o pipefail
3 3 export DEBIAN_FRONTEND='noninteractive'
4 4  
5   -cd /home/vagrant
  5 +cd /home/$(whoami)
6 6  
7 7 # Installing nvm
8 8 wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
9 9  
10 10 # This enables NVM without a logout/login
11   -export NVM_DIR="/home/vagrant/.nvm"
  11 +export NVM_DIR="/home/"$(whoami)"/.nvm"
12 12 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
13 13  
14 14 # Install a node and alias
15   -nvm install iojs
16   -nvm alias default iojs
  15 +nvm install node
  16 +nvm alias default node
17 17  
18 18 rm -Rf barra-govbr/
19 19 GIT_SSL_NO_VERIFY=true git clone http://portal.softwarepublico.gov.br/gitlab/govbr/barra-govbr.git
20 20  
21 21 cd barra-govbr
22 22  
23   -PROFILE=default make run
  23 +PROFILE=default make test
... ...
provision_root.sh
... ... @@ -2,14 +2,36 @@
2 2 set -e -x -o pipefail
3 3 export DEBIAN_FRONTEND='noninteractive'
4 4  
5   -sudo apt-get update
  5 +apt-get update
6 6  
7 7 apt-get install -y \
  8 + apt-transport-https \
  9 + ca-certificates \
  10 + curl \
8 11 git \
  12 + linux-image-extra-$(uname -r) \
  13 + linux-image-extra-virtual \
9 14 python-dev \
10 15 python-pip \
11 16 python-virtualenv \
12 17 ruby
13 18  
  19 +curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add -
  20 +
  21 +add-apt-repository \
  22 + "deb https://apt.dockerproject.org/repo/ \
  23 + ubuntu-$(lsb_release -cs) \
  24 + main"
  25 +
  26 +apt-get update
  27 +
  28 +apt-get -y install docker-engine
  29 +
  30 +usermod -aG docker ubuntu
  31 +
  32 +curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  33 +
  34 +chmod +x /usr/local/bin/docker-compose
  35 +
14 36 gem install sass
15 37  
... ...
test/app.js
... ... @@ -1,32 +0,0 @@
1   -var express = require("express");
2   -
3   -var app = express();
4   -
5   -
6   - // read the port from the environment, else set to 3000
7   - app.set("port", process.env.PORT || 3000);
8   - app.set('view engine', 'ejs');
9   -
10   -app.get('/', function (req, res)
11   -{
12   - res.render('index');
13   -});
14   -
15   -app.get('/barra.js', function (req, res)
16   -{
17   - res.render('barra');
18   -});
19   -
20   -app.get('/jquery.js', function (req, res)
21   -{
22   - res.render('jquery');
23   -});
24   -
25   -app.get('/static/opensans-bold.woff', function (req, res)
26   -{
27   - res.render('opensansbold');
28   -});
29   -
30   -// instead of starting the application here, export the app so that it can
31   -// be loaded differently based on the use case (running the app vs testing)
32   -module.exports = app;
test/zombie-test.js
... ... @@ -2,34 +2,65 @@ var chai = require(&quot;chai&quot;), plugin = require(&quot;chai-jq&quot;);
2 2 chai.use(plugin);
3 3  
4 4 var expect = require("chai").expect,
5   - Browser = require("zombie"),
6   - app = require("./app");
  5 + Browser = require("zombie");
7 6  
8 7 describe("Testes de conteúdo de HTML da barra", function() {
9   - var server, browser, barraUrl, barraFonte;
10   - barraUrl = "http://localhost:3000/";
11   - barraFonte = "http://localhost:3000/static/opensans-bold.woff";
12   - before(function() {
13   - server = app.listen(3000);
14   - });
  8 + var browser, barraUrl, barraFonte;
  9 + barraUrl = "http://localhost/";
  10 + barraFonte = "http://localhost/static/opensans-bold.woff";
15 11  
16 12 beforeEach(function() {
17 13 browser = new Browser();
18 14 browser.runScripts = true;
19 15 });
20 16  
21   - after(function() {
22   - // depois dos testes fechar o servidor
23   - server.close();
24   - });
25   -
26   - it("trocar o conteúdo do #barra-brasil pelo correto", function(done) {
  17 + it("trocar o conteúdo do #barra-brasil pelo correto em pt-BR", function(done) {
  18 + if (!browser.headers) {
  19 + browser.headers = {};
  20 + }
  21 + browser.headers['Accept-Language'] = 'pt-BR';
27 22 browser.visit(barraUrl, function() {
28 23 var inner_barra = browser.document.getElementById("barra-brasil");
29 24 expect(inner_barra.innerHTML).to.equal("<div id=\"wrapper-barra-brasil\"><div class=\"brasil-flag\"><a href=\"http://brasil.gov.br\" class=\"link-barra\">Brasil</a></div><span class=\"acesso-info\"><a href=\"http://www.servicos.gov.br/?pk_campaign=barrabrasil&amp;orgao=http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981\" class=\"link-barra\" id=\"barra-brasil-orgao\">Serviços</a></span><nav><ul class=\"list\"><li><a href=\"#\" id=\"menu-icon\"></a></li><li class=\"list-item first\"><a href=\"http://brasil.gov.br/barra#participe\" class=\"link-barra\">Participe</a></li><li class=\"list-item\"><a href=\"http://brasil.gov.br/barra#acesso-informacao\" class=\"link-barra\">Acesso à informação</a></li><li class=\"list-item\"><a href=\"http://www.planalto.gov.br/legislacao\" class=\"link-barra\">Legislação</a></li><li class=\"list-item last last-item\"><a href=\"http://brasil.gov.br/barra#orgaos-atuacao-canais\" class=\"link-barra\">Canais</a></li></ul></nav><a class=\"logo-vlibras\" href=\"http://www.vlibras.gov.br/\" aria-label=\"Acessível em Libras\"></a></div>");
30 25 done();
31 26 });
32 27 });
  28 +
  29 + it("trocar o conteúdo do #barra-brasil pelo correto em en", function(done) {
  30 + if (!browser.headers) {
  31 + browser.headers = {};
  32 + }
  33 + browser.headers['Accept-Language'] = 'en';
  34 + browser.visit(barraUrl, function() {
  35 + var inner_barra = browser.document.getElementById("barra-brasil");
  36 + expect(inner_barra.innerHTML).to.equal("<div id=\"wrapper-barra-brasil\"><div class=\"brasil-flag\"><a href=\"http://brasil.gov.br\" class=\"link-barra\">Brazil</a></div><span class=\"acesso-info\"><a href=\"http://www.servicos.gov.br/?pk_campaign=barrabrasil&amp;orgao=http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981\" class=\"link-barra\" id=\"barra-brasil-orgao\">Services</a></span><nav><ul class=\"list\"><li><a href=\"#\" id=\"menu-icon\"></a></li><li class=\"list-item first\"><a href=\"http://brasil.gov.br/barra#participe\" class=\"link-barra\">Participate</a></li><li class=\"list-item\"><a href=\"http://brasil.gov.br/barra#acesso-informacao\" class=\"link-barra\">Information access</a></li><li class=\"list-item\"><a href=\"http://www.planalto.gov.br/legislacao\" class=\"link-barra\">Legislation</a></li><li class=\"list-item last last-item\"><a href=\"http://brasil.gov.br/barra#orgaos-atuacao-canais\" class=\"link-barra\">Information channels</a></li></ul></nav><a class=\"logo-vlibras\" href=\"http://www.vlibras.gov.br/\" aria-label=\"Acessible in Brazilian Sign Language\"></a></div>");
  37 + done();
  38 + });
  39 + });
  40 +
  41 + it("trocar o conteúdo do #barra-brasil pelo correto em es", function(done) {
  42 + if (!browser.headers) {
  43 + browser.headers = {};
  44 + }
  45 + browser.headers['Accept-Language'] = 'es';
  46 + browser.visit(barraUrl, function() {
  47 + var inner_barra = browser.document.getElementById("barra-brasil");
  48 + expect(inner_barra.innerHTML).to.equal("<div id=\"wrapper-barra-brasil\"><div class=\"brasil-flag\"><a href=\"http://brasil.gov.br\" class=\"link-barra\">Brasil</a></div><span class=\"acesso-info\"><a href=\"http://www.servicos.gov.br/?pk_campaign=barrabrasil&amp;orgao=http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981\" class=\"link-barra\" id=\"barra-brasil-orgao\">Servicios</a></span><nav><ul class=\"list\"><li><a href=\"#\" id=\"menu-icon\"></a></li><li class=\"list-item first\"><a href=\"http://brasil.gov.br/barra#participe\" class=\"link-barra\">Participar</a></li><li class=\"list-item\"><a href=\"http://brasil.gov.br/barra#acesso-informacao\" class=\"link-barra\">Acceso a la información</a></li><li class=\"list-item\"><a href=\"http://www.planalto.gov.br/legislacao\" class=\"link-barra\">Legislación</a></li><li class=\"list-item last last-item\"><a href=\"http://brasil.gov.br/barra#orgaos-atuacao-canais\" class=\"link-barra\">Canales de información</a></li></ul></nav><a class=\"logo-vlibras\" href=\"http://www.vlibras.gov.br/\" aria-label=\"Acesso a la Libras\"></a></div>");
  49 + done();
  50 + });
  51 + });
  52 +
  53 + it("trocar o conteúdo do #barra-brasil pelo correto em fr", function(done) {
  54 + if (!browser.headers) {
  55 + browser.headers = {};
  56 + }
  57 + browser.headers['Accept-Language'] = 'fr';
  58 + browser.visit(barraUrl, function() {
  59 + var inner_barra = browser.document.getElementById("barra-brasil");
  60 + expect(inner_barra.innerHTML).to.equal("<div id=\"wrapper-barra-brasil\"><div class=\"brasil-flag\"><a href=\"http://brasil.gov.br\" class=\"link-barra\">Brésil</a></div><span class=\"acesso-info\"><a href=\"http://www.servicos.gov.br/?pk_campaign=barrabrasil&amp;orgao=http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/2981\" class=\"link-barra\" id=\"barra-brasil-orgao\">Prestations de service</a></span><nav><ul class=\"list\"><li><a href=\"#\" id=\"menu-icon\"></a></li><li class=\"list-item first\"><a href=\"http://brasil.gov.br/barra#participe\" class=\"link-barra\">Prende part</a></li><li class=\"list-item\"><a href=\"http://brasil.gov.br/barra#acesso-informacao\" class=\"link-barra\">Accès à l'information</a></li><li class=\"list-item\"><a href=\"http://www.planalto.gov.br/legislacao\" class=\"link-barra\">Législation</a></li><li class=\"list-item last last-item\"><a href=\"http://brasil.gov.br/barra#orgaos-atuacao-canais\" class=\"link-barra\">Les canaux d'information</a></li></ul></nav><a class=\"logo-vlibras\" href=\"http://www.vlibras.gov.br/\" aria-label=\"Accessible en brésilien langue des signes\"></a></div>");
  61 + done();
  62 + });
  63 + });
33 64  
34 65 it("trocar o conteúdo do #footer-brasil pelo correto", function(done) {
35 66 browser.visit(barraUrl, function() {
... ... @@ -41,11 +72,30 @@ describe(&quot;Testes de conteúdo de HTML da barra&quot;, function() {
41 72  
42 73 it("A fonte deve estar respondendo", function(done) {
43 74 browser.visit(barraFonte, function() {
  75 + expect(browser.response.headers._headers[3]).to.include.members(['etag']);
  76 + expect(browser.response.headers._headers[9]).to.include.members(['access-control-allow-origin', '*']);
  77 + expect(browser.response.headers._headers[11]).to.include.members(["content-type","application/x-font-woff"]);
44 78 expect(browser.response.status).to.equal(200);
45 79 done();
46 80 });
47 81 });
48 82  
  83 + it("Cabeçalhos HTTP do barra.js devem estar ok", function(done) {
  84 + if (!browser.headers) {
  85 + browser.headers = {};
  86 + }
  87 + browser.headers['Accept-Encoding'] = 'gzip';
  88 + browser.visit("http://localhost/barra.js", function() {
  89 + expect(browser.response.headers._headers[6]).to.include.members(['etag']);
  90 + expect(browser.response.headers._headers[8]).to.include.members(['content-encoding', 'gzip']);
  91 + expect(browser.response.headers._headers[9]).to.include.members(['cache-control','max-age=604800']);
  92 + expect(browser.response.headers._headers[11]).to.include.members(['access-control-allow-origin', '*']);
  93 + expect(browser.response.status).to.equal(200);
  94 + done();
  95 + });
  96 + });
  97 +
  98 +
49 99 it("a barra deve ter o css correto para visualizacao maior que 960px");
50 100  
51 101 it("a barra deve ter o css correto para visualização menor que 960px");
... ...
views/barra.ejs
... ... @@ -1 +0,0 @@
1   -<% include ../app/static/barra-brasil.js %>
views/index.ejs
... ... @@ -1 +0,0 @@
1   -<% include ../app/templates/exemplo.html %>
views/jquery.ejs
... ... @@ -1 +0,0 @@
1   -<% include ../app/static/jquery-2.1.3.min.js %>
views/opensansbold.ejs
... ... @@ -1 +0,0 @@
1   -<% include ../app/static/opensans-bold.woff %>