Giter Club home page Giter Club logo

gotestinfa's Introduction

gotestinfra

  • This is just POC for a library to support testing infrastructure as part of ansible playbooks

Examples

  1. Filesystem objects
// FILES/DIRS
	HOME := FileSystemObject{Path: "/home"}	
	HOME.HasMode("drwxr-xr-x")
	HOME.IsDir()
  1. Venv - python virtual environment
// VENV
	VENV := NewVenv("/data/virtualenv/default")
	VENV.dir.IsDir()
	VENV.dir.HasMode("drwx------")
	VENV.dir.OwnedByUser("deploy")
    VENV.dir.OwnedByGroup("deploy")
    VENV.PackageImportable("chardet", "3.0.4")
  • RAM
	// RAM
	RAM := RAM{}
	RAM.Total("GB").GreaterThan(0.9)
	RAM.Free("GB").GreaterThan(0.2)
	RAM.SwapTotal("GB").LowerThan(2.0)
	RAM.SwapTotal("GB").GreaterThan(1.0)
	RAM.SwapFree("GB").GreaterThan(1.0)
	RAM.Buffers("KB").LowerThan(10000)
	RAM.Cached("GB").LowerThan(1)
  • Diks mount
	// DISK MOUNTS
	MOUNTS := Mounts{}
	MOUNTS.HasMountPoint("/vagrant")
  • RPM
	// RPM
	RPM := rpm{}
	RPM.IsInstalled("git")
	RPM.IsInstalledVersion("git","1.8.3.1")
	RPM.IsInstalledRelease("git","14.el7_5")
  • Performance : Usuaally the tests are running very fast(less than 1sec )

      real    0m0.672s
      user    0m0.604s
      sys     0m0.238s
  • if you want to execute the tests concurrently you need to add count wg.Add(1) to waiting group and execute the normal test with go prefix , full example:

      // register task to wait for 
      wg.Add(1); 
           go VENV.PackageImportable("chardet", "3.0.4")
      // wait for concurrent go routines to finish before exiting
      wg.Wait()

gotestinfa's People

Contributors

nikoren avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.