any error needs to be recorded
|
f . AddError ( err . Error ( ) )
}
}
return response . Configuration
}
func checkNumberOfConfigurations ( f * frisby . Frisby , configurations [ ] ClusterConfiguration , expected int ) {
if len ( configurations ) != expected {
f . AddError ( fmt . Sprintf ( "Number of returned configurations %d differs from expected number %d" , len ( configurations ) , expected ) )
}
}
func checkInitialListOfConfigurations ( ) {
f := frisby . Create ( "Check list of configurations" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkEnableExistingConfiguration ( ) {
f := frisby . Create ( "Check that configuration can be enabled" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Put ( API_URL + "client/configuration/0/enable" )
f . Send ( )
f . ExpectStatus ( 200 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected = [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkDisableExistingConfiguration ( ) {
f := frisby . Create ( "Check that configuration can be disabled" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Put ( API_URL + "client/configuration/0/disable" )
f . Send ( )
f . ExpectStatus ( 200 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected = [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkEnableNonExistingConfiguration ( ) {
f := frisby . Create ( "Check what happens when non existing configuration is enabled" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Put ( API_URL + "client/configuration/42/enable" )
f . Send ( )
f . ExpectStatus ( 404 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected = [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkDisableNonExistingConfiguration ( ) {
f := frisby . Create ( "Check what happens when non existing configuration is disabled" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Put ( API_URL + "client/configuration/42/enable" )
f . Send ( )
f . ExpectStatus ( 404 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected = [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkDeleteExistingConfiguration ( ) {
f := frisby . Create ( "Check what happens when existing configuration is deleted" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 6 )
expected := [ ] ClusterConfiguration {
{ 0 , "00000000-0000-0000-0000-000000000000" , "0" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Delete ( API_URL + "client/configuration/0" )
f . Send ( )
f . ExpectStatus ( 200 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 5 )
expected = [ ] ClusterConfiguration {
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkDeleteNonExistingConfiguration ( ) {
f := frisby . Create ( "Check what happens when non existing configuration is deleted" )
configurations := readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 5 )
expected := [ ] ClusterConfiguration {
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . Delete ( API_URL + "client/configuration/42" )
f . Send ( )
f . ExpectStatus ( 404 )
configurations = readConfigurations ( f )
checkNumberOfConfigurations ( f , configurations , 5 )
expected = [ ] ClusterConfiguration {
{ 1 , "00000000-0000-0000-0000-000000000000" , "1" , "2019-01-01T00:00:00Z" , "tester" , "0" , "no reason" } ,
{ 2 , "00000000-0000-0000-0000-000000000000" , "2" , "2019-01-01T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 3 , "00000000-0000-0000-0000-000000000001" , "1" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason" } ,
{ 4 , "00000000-0000-0000-0000-000000000002" , "2" , "2019-10-11T00:00:00Z" , "tester" , "1" , "no reason so far" } ,
{ 5 , "00000000-0000-0000-0000-000000000003" , "0" , "2019-10-11T00:00:00Z" , "tester" , "0" , "disabled one" } ,
}
compareConfigurations ( f , configurations , expected )
f . PrintReport ( )
}
func checkDescribeExistingConfiguration ( ) {
f := frisby . Create ( "Check describing (reading) existing configuration" )
f . Get ( API_URL + "client/configuration/1" )
f . Send ( )
f . ExpectStatus ( 200 )
f . ExpectContent ( `{"configuration":"{\"no_op\":\"X\", \"watch\":[\"a\",\"b\",\"c\"]}","status":"ok"}` )
f . PrintReport ( )
}
func checkDescribeNonExistingConfiguration ( ) {
f := frisby . Create ( "Check describing (reading) non existing configuration" )
f . Get ( API_URL + "client/configuration/42" )
f . Send ( )
f . ExpectStatus ( 404 )
f . PrintReport ( )
}
|