Skip to content

Commit fd1c770

Browse files
authored
Update backend API from Atlas Data API to Azure functions (#14)
2 parents a89a0e4 + 063765a commit fd1c770

21 files changed

+375
-843
lines changed

__tests__/pages/api/findresources.test.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import resources from "./resources.json"
44
const originalEnv = process.env;
55

66
global.fetch = jest.fn((url) => {
7-
if (url.includes("data.mongodb-api")) {
7+
if (url.includes("api.gem5")) {
88
return Promise.resolve({
9-
json: () => Promise.resolve({
10-
'documents': [],
11-
}),
9+
json: () => Promise.resolve(
10+
[],
11+
),
1212
})
1313
}
1414

@@ -18,14 +18,6 @@ global.fetch = jest.fn((url) => {
1818
})
1919
}
2020

21-
if (url.includes("realm.mongodb.com")) {
22-
return Promise.resolve({
23-
json: () => Promise.resolve({
24-
"access_token": ""
25-
}),
26-
})
27-
}
28-
2921
return Promise.resolve({
3022
json: () => Promise.resolve({
3123
"error": "Resource not found"
@@ -146,9 +138,7 @@ describe('findResources', () => {
146138
dataSource: "gem5-vision",
147139
database: "gem5-vision",
148140
collection: "resources",
149-
url: "https://data.mongodb-api.com/app/data-ejhjf/endpoint/data/v1",
150-
authUrl: "https://realm.mongodb.com/api/client/v2.0/app/data-ejhjf/auth/providers/api-key/login",
151-
apiKey: "pKkhRJGJaQ3NdJyDt69u4GPGQTDUIhHlx4a3lrKUNx2hxuc8uba8NrP3IVRvlzlo",
141+
url: "https://api.gem5.org/api/resources",
152142
isMongo: true,
153143
}
154144
}
@@ -169,9 +159,7 @@ describe('findResources', () => {
169159
dataSource: "gem5-vision",
170160
database: "gem5-vision",
171161
collection: "resources",
172-
url: "https://data.mongodb-api.com/app/data-ejhjf/endpoint/data/v1",
173-
authUrl: "https://realm.mongodb.com/api/client/v2.0/app/data-ejhjf/auth/providers/api-key/login",
174-
apiKey: "pKkhRJGJaQ3NdJyDt69u4GPGQTDUIhHlx4a3lrKUNx2hxuc8uba8NrP3IVRvlzlo",
162+
url: "https://api.gem5.org/api/resources",
175163
isMongo: true,
176164
}
177165
}

__tests__/pages/api/getVersions.test.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import resources from "./resources.json"
44
const originalEnv = process.env;
55

66
global.fetch = jest.fn((url) => {
7-
if (url.includes("data.mongodb-api")) {
7+
if (url.includes("api.gem5")) {
88
return Promise.resolve({
99
status: 200,
10-
json: () => Promise.resolve({
11-
'documents': [
10+
json: () => Promise.resolve(
11+
[
1212
{
1313
"category": "simpoint",
1414
"id": "batman",
@@ -18,7 +18,6 @@ global.fetch = jest.fn((url) => {
1818
"database": "db1"
1919
}
2020
]
21-
}
2221
),
2322
})
2423
}
@@ -30,15 +29,6 @@ global.fetch = jest.fn((url) => {
3029
})
3130
}
3231

33-
if (url.includes("realm.mongodb.com")) {
34-
return Promise.resolve({
35-
status: 200,
36-
json: () => Promise.resolve({
37-
"access_token": ""
38-
}),
39-
})
40-
}
41-
4232
return Promise.resolve({
4333
status: 200,
4434
json: () => Promise.resolve({
@@ -107,9 +97,7 @@ describe("getVersions", () => {
10797
dataSource: "gem5-vision",
10898
database: "gem5-vision",
10999
collection: "versions_test",
110-
url: "https://data.mongodb-api.com/app/data-ejhjf/endpoint/data/v1",
111-
authUrl: "https://realm.mongodb.com/api/client/v2.0/app/data-ejhjf/auth/providers/api-key/login",
112-
apiKey: "pKkhRJGJaQ3NdJyDt69u4GPGQTDUIhHlx4a3lrKUNx2hxuc8uba8NrP3IVRvlzlo",
100+
url: "https://api.gem5.org/api/resources",
113101
isMongo: true,
114102
},
115103
}

__tests__/pages/api/getfilters.test.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@ import resources from "./resources.json"
44
const originalEnv = process.env;
55

66
global.fetch = jest.fn((url) => {
7-
if (url.includes("data.mongodb-api")) {
7+
if (url.includes("api.gem5")) {
88
return Promise.resolve({
99
status: 200,
10-
json: () => Promise.resolve({
11-
'documents': [
10+
json: () => Promise.resolve(
1211
{
1312
"category": ["simpoint", "file"],
1413
"id": "batman",
15-
"architecture": ["X86", "ARM", null],
14+
"architecture": ["X86", "ARM"],
1615
"tags": [],
1716
"resource_version": "1.0.0",
1817
"gem5_versions": ["22.0"],
1918
"database": "db1",
2019
},
21-
]
22-
}),
20+
),
2321
})
2422
}
2523

@@ -30,15 +28,6 @@ global.fetch = jest.fn((url) => {
3028
})
3129
}
3230

33-
if (url.includes("realm.mongodb.com")) {
34-
return Promise.resolve({
35-
status: 200,
36-
json: () => Promise.resolve({
37-
"access_token": ""
38-
}),
39-
})
40-
}
41-
4231
return Promise.resolve({
4332
status: 200,
4433
json: () => Promise.resolve({
@@ -85,9 +74,7 @@ describe('getFilters', () => {
8574
dataSource: "gem5-vision",
8675
database: "gem5-vision",
8776
collection: "versions_test",
88-
url: "https://data.mongodb-api.com/app/data-ejhjf/endpoint/data/v1",
89-
authUrl: "https://realm.mongodb.com/api/client/v2.0/app/data-ejhjf/auth/providers/api-key/login",
90-
apiKey: "pKkhRJGJaQ3NdJyDt69u4GPGQTDUIhHlx4a3lrKUNx2hxuc8uba8NrP3IVRvlzlo",
77+
url: "https://api.gem5.org/api/resources",
9178
isMongo: true,
9279
},
9380
}

__tests__/pages/api/getresource.test.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import resources from "./resources.json"
44
const originalEnv = process.env;
55

66
global.fetch = jest.fn((url) => {
7-
if (url.includes("data.mongodb-api")) {
7+
if (url.includes("api.gem5")) {
88
return Promise.resolve({
99
status: 200,
10-
json: () => Promise.resolve({
11-
'documents': [{
10+
json: () => Promise.resolve(
11+
[{
1212
category: 'simpoint',
1313
id: 'batman',
1414
description: 'Simpoints for running the \'x86-print-this\' resource with the parameters `"print this" 15000`. This is encapsulated in the \'x86-print-this-15000-with-simpoints\' workload.',
@@ -32,7 +32,7 @@ global.fetch = jest.fn((url) => {
3232
workloads_mapping: [],
3333
database: 'db1'
3434
}],
35-
}),
35+
),
3636
})
3737
}
3838

@@ -43,15 +43,6 @@ global.fetch = jest.fn((url) => {
4343
})
4444
}
4545

46-
if (url.includes("realm.mongodb.com")) {
47-
return Promise.resolve({
48-
status: 200,
49-
json: () => Promise.resolve({
50-
"access_token": ""
51-
}),
52-
})
53-
}
54-
5546
return Promise.resolve({
5647
status: 200,
5748
json: () => Promise.resolve({
@@ -187,9 +178,7 @@ describe('getResource', () => {
187178
dataSource: "gem5-vision",
188179
database: "gem5-vision",
189180
collection: "resources",
190-
url: "https://data.mongodb-api.com/app/data-ejhjf/endpoint/data/v1",
191-
authUrl: "https://realm.mongodb.com/api/client/v2.0/app/data-ejhjf/auth/providers/api-key/login",
192-
apiKey: "pKkhRJGJaQ3NdJyDt69u4GPGQTDUIhHlx4a3lrKUNx2hxuc8uba8NrP3IVRvlzlo",
181+
url: "https://api.gem5.org/api/resources",
193182
isMongo: true,
194183
}
195184
}

cypress/e2e/searchPage.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ describe('Search page', () => {
55
cy.interceptAll()
66
cy.visit('/resources')
77
cy.waitAuto()
8-
cy.waitAuto()
98
window.localStorage.setItem('CookieConsent', "{\"userPreference\":\"all\"}")
109
})
1110

@@ -112,6 +111,7 @@ describe('Search page', () => {
112111
})
113112

114113
it('checks if changing page size works', () => {
114+
// cy.waitAuto()
115115
cy.get('.results-sortBy-row').find('select').first().select('25')
116116
cy.waitAuto()
117117
// cy.wait(['@kiwi', '@resources', '@mongo'])

cypress/fixtures/filters.json

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
{
2-
"documents": [
3-
{
4-
"_id": null,
5-
"category": [
6-
"workload",
7-
"simpoint",
8-
"disk_image",
9-
"binary",
10-
"checkpoint",
11-
"bootloader",
12-
"resource",
13-
"kernel"
14-
],
15-
"architecture": [
16-
"X86",
17-
"ARM",
18-
"MIPS",
19-
"RISCV",
20-
"POWER",
21-
"SPARC"
22-
],
23-
"gem5_versions": [
24-
"23.0"
25-
]
26-
}
2+
"_id": null,
3+
"category": [
4+
"workload",
5+
"simpoint",
6+
"disk_image",
7+
"binary",
8+
"checkpoint",
9+
"bootloader",
10+
"resource",
11+
"kernel"
12+
],
13+
"architecture": [
14+
"X86",
15+
"ARM",
16+
"MIPS",
17+
"RISCV",
18+
"POWER",
19+
"SPARC"
20+
],
21+
"gem5_versions": [
22+
"23.0"
2723
]
28-
}
24+
}

0 commit comments

Comments
 (0)