Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new functional tests suite #769

Merged
merged 16 commits into from
Nov 22, 2023
Merged

Conversation

mapedraza
Copy link
Collaborator

@mapedraza mapedraza commented Oct 19, 2023

This PR includes a new "functional" test suite. It should:

Things to have into account in this suite:

  • Be more verbose (including diffs)
  • More legible and easy to build
  • Make tests independents between them

Copy link
Member

@mrutid mrutid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor.
The structure looks good to me.

deviceRegistrationDuration: 'P1M',
defaultType: 'Thing',
defaultResource: '/iot/json',
compressTimestamp: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it appears again? in any case should be false.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is inherited from previous unit tests config file. I will remove here and open a new PR to remove it from the rest of config files

test/functional/functional-tests.js Outdated Show resolved Hide resolved
test/functional/functional-tests.js Outdated Show resolved Hide resolved
});
});

describe('Basic group provision with attributes', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to refer to the attributes as "active attributes"

@mapedraza
Copy link
Collaborator Author

After committing ce2e261 tests are more verbose, you can check how an expectation that differs from the CB payload looks like:
https://github.com/telefonicaid/iotagent-json/actions/runs/6589901511/job/17905362907?pr=769#step:5:287

It is made to intentionally make tests fail for demonstration purposes.

CC: @manucarrace @mrutid

@mapedraza
Copy link
Collaborator Author

It also detects problems when sending the request (southbound) or when provisioning wrongly:
image

package.json Outdated
"test:coverage": "nyc --reporter=lcov mocha -- --recursive 'test/**/*.js' --reporter spec --exit",
"test:coveralls": "npm run test:coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"test:watch": "npm run test -- -w ./lib",
"watch": "watch 'npm test && npm run lint' ./lib ./test"
},
"devDependencies": {
"async-mqtt": "~2.6.3",
"chai": "^4.3.10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use ^. Always ~

;)

@@ -29,12 +29,15 @@
"prettier:text": "prettier 'README.md' 'docs/*.md' 'docs/**/*.md' --no-config --tab-width 4 --print-width 120 --write --prose-wrap always",
"start": "node ./bin/iotagent-json",
"test": "nyc --reporter=text mocha --recursive 'test/**/*.js' --reporter spec --timeout 5000 --ui bdd --exit --color true",
"test:functional": "nyc --reporter=text mocha --recursive 'test/functional/*.js' --reporter spec --timeout 5000 --ui bdd --exit --color true",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A GitAction for this test should be included.

Copy link
Collaborator Author

@mapedraza mapedraza Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real needed since they are executed as part of normal tests 'test/**/*.js'. In other words, functional tests are executed as part of normal tests (npm test).

Unless we want to add a new section under CI tests, it is not required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, why don't just keep test target and remove test:functional?

Not sure if having overlapping targets is a good idea...

@mapedraza
Copy link
Collaborator Author

mapedraza commented Oct 30, 2023

The test that expects the measures includes metadata with TimeInstant when timestamp=true is failing just because of the date, neeeds to be fixed.

A - WHEN sending a measure not named TimeInstant through http IT should add the timestamp to the attributes sent to Context Broker

@mapedraza mapedraza marked this pull request as ready for review November 22, 2023 09:32
package.json Outdated Show resolved Hide resolved
@fgalan
Copy link
Member

fgalan commented Nov 22, 2023

As discussed at Teams, a test/functional/README.md would be a good idea.

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fgalan fgalan merged commit a65c013 into master Nov 22, 2023
6 checks passed
@fgalan fgalan deleted the task/add-functional-tests-suite branch November 22, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants