North-Seattle-College / ad440-winter2020-thursday-repo

Repository for AD440 Thursday Class in Winter 2020
Apache License 2.0
10 stars 5 forks source link

Test Clean the Development Environment #247

Open mattyplo opened 4 years ago

mattyplo commented 4 years ago

test task #246

mattyplo commented 4 years ago

Testing: Cleaning the Dev Environment

Make Sure The Lambdas Are Create

Because we are going to be using the development branch as our 'production' branch, we need to make sure we have all the lambdas created that conform to our swagger documentation. A quick manual check in the AWS console is all that is needed to confirm that indeed, the 'production' lambdas have been created and exist.

image

In addition, Lambdas were created for the API team to develop their sprint5 Lambdas on.

image

Note: When we test the API gateway, we will also be testing that indeed the Lambda functions are working or at least built.

we will reuse the DB

A quick check in our AWS console will confirm that the database that exists, is the same database that is being used by the Prod Lambdas. Checking that the environment variables in the Prod Lambdas is the same as the Aurora Database in our AWS console will confirm this.

image above is a prod lambda view from the AWS console.

image We can see that the endpoint of the above database is the same as the endpoint referenced in the prod Lambda.

Note: When we test the API gateway, we will be also testing the database, as the database being used is indeed the same Aurora Database from the sprints prior.

need to make sure the API GW is properly configured for https://api.2edusite.com

For this we will visually confirm that indeed the API gateway is setup. It is.
However, a more in depth testing using postman to test these API endpoints will confirm that the Gateway is setup properly and if we get back proper responses, then we will see that indeed the Database and Lambdas are also set up. A proper response for the database would be that the API endpoint returns data from our RDS. And likewise, a return of data from the RDS would also mean that we have a functional Lambda.

Note: I will be using postman for these HTTP request tests. Authorization: Bear Token -> via a successful sign in at Sign In

Test 1

GET -> https://api.2edusite.com/v1/property Response:

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'serverless-mysql'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "trace": [
        "Runtime.ImportModuleError: Error: Cannot find module 'serverless-mysql'",
        "Require stack:",
        "- /var/task/index.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/index.js",
        "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:955:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)",
        "    at Module.load (internal/modules/cjs/loader.js:811:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:723:14)",
        "    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)",
        "    at internal/main/run_main_module.js:17:11"
    ]
}

Results: Success. The error Message is due to missing modules in the Lambda directory. However, Lambda did indeed fire. The API Gateway was able to do it's job as well. The only thing is that this does not answer the question of whether or not we are getting a response from the DB since we didn't have a proper module to connect with.

Test 2

GET -> https://api.2edusite.com/v1/keyholder Response:

[
    {
        "keyholder_id": 1,
        "first_name": "Northgate",
        "last_name": "office",
        "email": "info@umanopm.com",
        "phone": "2066863661",
        "keyholder_type_id": 1,
        "keyholder_type": "management company"
    },
    {
        "keyholder_id": 2,
        "first_name": "Alberto",
        "last_name": "Stein Rios",
        "email": "info@umanopm.com",
        "phone": "2066863661",
        "keyholder_type_id": 1,
        "keyholder_type": "management company"
    },
    {
        "keyholder_id": 3,
        "first_name": "Alice",
        "last_name": "Allium",
        "email": "alice@tree.com",
        "phone": "123456",
        "keyholder_type_id": 2,
        "keyholder_type": "plummer"
    },

Note: The above response only includes the first three entries from the DB. Results: Success. The Gateway worked, we connected to the Database and got data back from the database.

Test 3

GET -> https://api.2edusite.com/v1/keyholder/1 Response:

{
    "statusCode": 200,
    "body": "\"Hello from Lambda!\""
}

Results: The API Gateway and the Lambda are both functioning properly. It appears that the Prod function hasn't been updated or written yet since we are seeing any results from the database and the response that we did get back looks generic.

Conclusion

From the results of our test, both through manual inspection of the AWS console and through our Postman HTTP requests, we can confirm that the Development / Production environment has been cleaned up and is functional.