Setting up a dev platform for Gladys 4

Hello,

It has been 2 days since my Raspberry Pi 4 was set up to create a small server to run Gladys 4. To make my modifications, I go directly through Git, as described in the documentation.

I have cloned the repository into a folder, installed the server and front-end via npm, migrated the database, but despite all this, I get these errors after running the tests:

Server side:

pi@raspberrypi:~/gladys/server $ npm test

> gladys-server@ pretest /home/pi/gladys/server
> cross-env SQLITE_FILE_PATH=/tmp/gladys-test.db npm run db-migrate:test && npm run eslint

> gladys-server@ db-migrate:test /home/pi/gladys/server
> cross-env NODE_ENV=test node_modules/.bin/sequelize db:migrate

Sequelize CLI [Node: 10.16.3, CLI: 5.4.0, ORM: 4.44.3]

Loaded configuration file "config/config.js".
Using environment "test".
== 20190211042644-create-calendar-event: migrating ==========

ERROR: SQLITE_ERROR: index t_calendar_event_calendar_id already exists

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gladys-server@ db-migrate:test: `cross-env NODE_ENV=test node_modules/.bin/sequelize db:migrate`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gladys-server@ db-migrate:test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-10-17T09_25_49_725Z-debug.log
npm ERR! Test failed.  See above for more details.

Front side:

pi@raspberrypi:~/gladys/server $ cd ../front/
pi@raspberrypi:~/gladys/front $ npm test

> gladys-front@ test /home/pi/gladys/front
> jest --coverage

 FAIL  tests/header.test.js
  Initial Test of the Header
    âś• Header renders Gladys Assistant title and 8 items in header (78ms)
    âś“ Should return null, login page doesnt need a header (2ms)
    âś• [Backslash URL] Header renders Gladys Assistant title and 8 items in header (17ms)
    âś“ [Backslash URL] Should return null, login page doesnt need a header (1ms)

  ● Initial Test of the Header › Header renders Gladys Assistant title and 8 items in header

    expect(received).toBe(expected)

    Expected value to be (using ===):
      "Gladys Assistant"
    Received:
      ""

      at Object.<anonymous> (tests/header.test.js:25:305)
          at new Promise (<anonymous>)

  ● Initial Test of the Header › [Backslash URL] Header renders Gladys Assistant title and 8 items in header

    expect(received).toBe(expected)

    Expected value to be (using ===):
      "Gladys Assistant"
    Received:
      ""

      at Object.<anonymous> (tests/header.test.js:25:728)
          at new Promise (<anonymous>)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 2 passed, 4 total
Snapshots:   0 total
Time:        1.956s
Ran all test suites.
-------------------|----------|----------|----------|----------|-------------------|
File               |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-------------------|----------|----------|----------|----------|-------------------|
All files          |      100 |    66.67 |      100 |      100 |                   |
 components/header |      100 |    57.14 |      100 |      100 |                   |
  index.jsx        |      100 |    57.14 |      100 |      100 |35,41,45,73,96,114 |
 utils             |      100 |      100 |      100 |      100 |                   |
  url.js           |      100 |      100 |      100 |      100 |                   |
-------------------|----------|----------|----------|----------|-------------------|
npm ERR! Test failed.  See above for more details.
pi@raspberrypi:~/gladys/front $

However, I do have sqlite3 installed, node and npm are running fine, and I am trying to install directly after cloning the Gladys repository.

On the server side, the problem would come from duplicate indexes in the database.
On the front side, I have an error in the definition of the Header.

Could you provide me with some research leads? I am very eager to start developing the services I need :grin:

Thank you in advance.

Petit up!

It’s been a week, and in the meantime, I’ve tried installing a server directly on my PC’s WSL. After installation, I’m exactly at the same level. Could someone be kind enough to help me please?

Thank you :wink:

Oops, sorry, I missed your message! :slight_smile:

Clearly, I advise you to run this on your Windows laptop, not on your Pi, it’s impossible to develop on Pi!

You need to delete the file /tmp/gladys-test.db, apparently your DB already exists (this is where the test DB is located). On Windows, I don’t know if this kind of path works? Maybe you need to change it.. (in the file server/package.json, in the place where the scripts are defined)

Yes it works in WSL :wink:

Thanks for your feedback! :grin:

After a hard day’s work, I finally managed to install my server, so I was able to check my first contributions:

The development of the Arduino service begins!

I have a lot of ideas regarding the configuration and interaction pages with the associated devices. I have a week off, so I will take advantage of it to make as much progress as possible. I will give you an update as soon as I have a functional start: wink:

Thanks again for your help :slightly_smiling_face:

Great @billona! Don’t hesitate if you have any questions :slight_smile:

Hello everyone,

This topic interests me (setting up a dev platform for Gladys 4).

I have the intuition that it is possible to do this with Docker.
I am not a DevOps and unfortunately have very little time to devote to this kind of thing.
Tell me if it seems possible to set up a dev platform with Docker by following a tutorial of the type:

  • Set up the docker with the docker-compose.yml => node image and a good volume mount
  • Place the Gladys v4 git in the mount
  • Build everything in dev mode

Wishing you a good day :slight_smile:

There’s nothing special to do for dev with Docker, just add a volume when creating it (the folder where Gladys is installed)

But it’s not practical because the image is for production (no hot reload)

WSL is the best under Windows

@renaiku, here’s the fairly simple process I followed

So, I did this a long time ago, so I didn’t follow the current documentation. It was already on my computer since its release, but I know it’s easy to set up. It installs a good old Ubuntu (or Debian or another, depending on your preferences)

You install WSL, you can go back to your project (or reinstall it as you prefer)
NOTE: To know, the c:// folder is in this form /mnt/c/ under WSL

Then, after that, you follow the standard installation under Windows for node modules that use the c:/ path from the gladys v4 documentation and you run the servers under WSL

and in theory, it should work perfectly ^^

Thanks @VonOx for the info :slight_smile:

@renaiku Personally, I would advise you to install nvm to switch Node versions whenever you want, well, if that’s not already the case ^^. It’s a bit of a hassle on Windows, but you’re so much more relaxed afterward ^^

Well, why do you want to rewrite the doc? WSL is Linux, so the dependencies are the same. Or did I misunderstand what you meant?

For your PATH, do you mean that node.exe was used under WSL? (That really surprises me)

Oh yes, I completely agree.

OK, I see, I’ve never had node Windows + WSL for that, so I’ve never encountered this problem.