Closed dradetsky closed 3 years ago
We currently only test and officially support LTS versions of node. We also test on 8. Do you have a requirement to use node 15?
We should definitely fix this issue though and the test is actually broken. On my machine the detection never throws:
it('should return an empty resource when timed out', async () => {
const expectedError = new Error('Failed to load page, status code: 404');
fileStub = sandbox
.stub(AwsEksDetector, 'fileAccessAsync' as any)
.resolves();
readStub = sandbox
.stub(AwsEksDetector, 'readFileAsync' as any)
.resolves(correctCgroupData);
getCredStub = sandbox
.stub(awsEksDetector, '_getK8sCredHeader' as any)
.resolves(k8s_token);
const scope = nock('https://' + K8S_SVC_URL)
.persist()
.get(AUTH_CONFIGMAP_PATH)
.matchHeader('Authorization', k8s_token)
.reply(404, () => new Error());
let thrown = false;
try {
await awsEksDetector.detect({
logger: new NoopLogger(),
});
} catch (err) {
thrown = true;
assert.deepStrictEqual(err, expectedError);
}
assert.ok(thrown); // <= this assertion fails on my machine (v14)
scope.done();
});
The name also mentions timeouts but the test doesn't appear to deal with any timing
@dyladan strictly speaking, we only have a hard requirement to use a version of node that supports async_hooks
, so LTS should be okay. However, the package in question (and all the other packages I've seen) have
"engines": {
"node": ">=8.0.0"
}
I studied math in college & I can confirm that 15.4.0 >= 8.0.0.
I'm not saying that's a bug or that you need to change your engines declarations. But a user could be forgiven for assuming you support 15.x.x releases.
@dyladan you said
The name also mentions timeouts but the test doesn't appear to deal with any timing
I'm guessing what's going on is that the above error is what occurs when there's a timeout in eks. It's not that the test involves timing, he's just having it trigger the error which would be triggered by a timeout immediately.
What (I'm guessing) the test is about is making sure that if this error occurs, the resource which we detect isn't in some incorrect garbage state, like if it got half the info & then timed out, the result should be empty, not with half the fields filled out. Or something like that (I don't really know the resource detector specifically).
What version of OpenTelemetry are you using?
the tip of master. Or
a2304c9a82b77c762ae5df0f8f8621b4e2ab5ecb
What version of Node are you using?
Please provide the code you used to setup the OpenTelemetry SDK
npm install && npm run compile && npm test
What did you do?
npm test
What did you expect to see?
The tests passing.
What did you see instead?
Additional context
which suggests to me that either:
0.a. this is not how you're actually supposed to do assert-exception-is-thrown in this test framework, or
0.b. the tests have some non-automatic & undocumented dependency that i don't have (e.g. the author of the package has a more recent version of mocha on his personal machine, and that's what runs for him rather than the version the package explicitly depends on).
In spite of the fact that I had only 1 error above, I now get
which is again the error we were trying to expect, not to trigger.