0.0.52 • Published 3 years ago

kubernetes-smktest v0.0.52

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
3 years ago

kubernetes-smktest:

This is a library for creating smoke tests on kubernetes-based clusters. It is developed to have a high degree of automation although there are levels that require user configuration.

Smoke tests: It is a type of stability test that must be applied before starting the rest of the deep tests. It is generally maintenance-free and can help detect stability issues in your architecture early.

Keyworld: Smoke Test, Sporadic failures, automatic, test, kubernetes

Content:

CommandsParametersTest TypeDescription
createNamespaceTestnot requiredFor ClusterVerify if the cluster has the ability to create new ones NewSpaces
createSecretTestnot requiredFor ClusterVerify if the cluster has the ability to create new ones Secrets
statusPodsnamespaceFor PodsVerify that the cluster services are available.
pingnamespaceFor PodsVerify that network connections are available.
logsStatenamespaceFor PodsVerify that there are no errors within the logs of each Pods.
smokeTestnamespace, smktestCriterial, urlSwaggerFor PodCheck backend stability.

1) Use Example Smoke Test Commands:

SmokeTest with Jest

Test create new namespace:

  const kubeSmktest = require("swagger-smktest");
  const ora = require("ora");

  test("Create temporary Namespace ", async () => {
        //!
        let passTest = await kubeSmktest.createNamespaceTest();

        let logsSpinner = ora(
            `* Create Namespace: Create namespace enviroment: passTest=${passTest}`
        ).start();

        if (!passTest) {
          logsSpinner.fail();
        } else {
         logsSpinner.succeed();
        }

        expect(passTest).toBe(true);

  });

, check the create kubernetes secret:

Test create new secret:

  const kubeSmktest = require("swagger-smktest");
  const ora = require("ora");

  test("Create temporary secret inside of the cluster", async () => {

        let passTest = await kubeSmktest.createSecretTest();

        let logsSpinner = ora(
          `* Create Secret: Create namespace and secret: passTest=${passTest}`
        ).start();

        if (!passTest) {
         logsSpinner.fail();
        } else {
         logsSpinner.succeed();
        }

        expect(passTest).toBe(true);

  });

Service Up:

  const kubeSmktest = require("swagger-smktest");
  const ora = require("ora");

  test("The pods are Active", async () => {
        // Define namespace:
        let namespace = "test-smktest";

        let { passTest, podsStatus, report } = await kubeSmktest.statusPods(
              namespace
        );

        let logsSpinner = ora(
         `* Service Up: Pods status Namespace: ${namespace}`
        ).start();

        // Test decorators:
        if (!passTest) {
           logsSpinner.fail();
           console.log(report.render());
        } else {
           logsSpinner.succeed();
        }

        expect(passTest).toBe(true);
  });

PingTCP perform all internal services:

  const kubeSmktest = require("swagger-smktest");
  const ora = require("ora");

  test("IPs are aLive:", async () => {

        //! Select namespaces:
        let namespace = "test-smktest";

        let { passTest, statusPingList, report } = await kubeSmktest.ping(namespace);

        // Information about the test status:
        let logsSpinner = ora(
          `* IP Adress is Alive: Namespace: ${namespace}`
        ).start();

        if (!passTest) {
          logsSpinner.fail();
          //! Print table report
          console.log(report.render());
        } else {
          logsSpinner.succeed();
        }

  expect(passTest).toBe(true);
  }, 6000);

Check if there are errors in the Logs within the Logs:

  const kubeSmktest = require("swagger-smktest");
  const ora = require("ora");

  test("Check logs service contents", async () => {
  let namespace = "smktest";
  let { passTest, podsStatus, report } = await kubeSmktest.logsState(namespace);


  let logsSpinner = ora(
    `* Logs Check: Kubernetes LogsPods Namespace: ${namespace}`
  ).start();


  if (!passTest) {
    logsSpinner.fail();
  } else {
   logsSpinner.succeed();
  }

  expect(passTest).toBe(true);
  });

Check Apis Endpoint only with swaggerURL parameter (1):

  test("Check Apis Endpoint only with swaggerURL", async () => {

    //! Swagger documentation:
    let urlSwagger = 'swaggerURL';

    //! Its possible use /swagger.json
    let smktestCriterial = "basic";

    let {
        responseOfRequest,
        coverage,
        successSmokeTest,
        report,
        abstractReport,
        } = await swaggerSmktest.smokeTest(smktestCriterial, urlSwagger);

   //! Pint reports fails:
  if (!successSmokeTest) {
    console.log(report.render());
    console.log(abstractReport.render());
  }

  expect(successSmokeTest).toBe(false); //TODO false only for test
  });

General Commands

Command libraryDescription
.......

Output console:

  example code fragment

IMAGE EXAMPLE toolss_200px

npm run test --inputs=0

0.0.51

3 years ago

0.0.52

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.0.3

3 years ago

0.0.37

3 years ago

0.0.38

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago