@@ -618,7 +618,7 @@ func TestRuntimeSpec(t *testing.T) {
618
618
Hostname : newString ("testHostName" ),
619
619
Sysctl : map [string ]string {"key1" : "val1" , "key2" : "val2" , "key3" : "val3" },
620
620
Quotas : aostypes.ServiceQuotas {
621
- CPULimit : newUint64 (42 ),
621
+ CPULimit : newUint64 (2000 ),
622
622
RAMLimit : newUint64 (1024 ),
623
623
PIDsLimit : newUint64 (10 ),
624
624
NoFileLimit : newUint64 (3 ),
@@ -987,6 +987,96 @@ func TestRuntimeSpec(t *testing.T) {
987
987
}
988
988
}
989
989
990
+ func TestMinCPUQuota (t * testing.T ) {
991
+ testData := testItem {
992
+ services : []serviceInfo {
993
+ {
994
+ ServiceInfo : aostypes.ServiceInfo {ServiceID : "service0" },
995
+ serviceConfig : & aostypes.ServiceConfig {
996
+ Quotas : aostypes.ServiceQuotas {
997
+ CPULimit : newUint64 (42 ),
998
+ },
999
+ },
1000
+ },
1001
+ },
1002
+ instances : []aostypes.InstanceInfo {
1003
+ {InstanceIdent : aostypes.InstanceIdent {ServiceID : "service0" , SubjectID : "subject0" , Instance : 0 }},
1004
+ },
1005
+ }
1006
+
1007
+ var currentTestItem testItem
1008
+
1009
+ runningInstances := make (map [string ]runner.InstanceStatus )
1010
+
1011
+ storage := newTestStorage ()
1012
+ serviceProvider := newTestServiceProvider ()
1013
+ layerProvider := newTestLayerProvider ()
1014
+ instanceRunner := newTestRunner (
1015
+ func (instanceID string ) runner.InstanceStatus {
1016
+ status := getRunnerStatus (instanceID , currentTestItem , storage )
1017
+ runningInstances [instanceID ] = status
1018
+
1019
+ return status
1020
+ },
1021
+ func (instanceID string ) error {
1022
+ delete (runningInstances , instanceID )
1023
+
1024
+ return nil
1025
+ },
1026
+ )
1027
+
1028
+ nodeInfoProvider := newTestNodeInfoProvider ()
1029
+ nodeInfoProvider .nodeInfo .MaxDMIPs = 100000
1030
+
1031
+ testLauncher , err := launcher .New (& config.Config {WorkingDir : tmpDir }, nodeInfoProvider , storage ,
1032
+ serviceProvider , layerProvider , instanceRunner , newTestResourceManager (), newTestNetworkManager (),
1033
+ newTestRegistrar (), newTestInstanceMonitor (), newTestAlertSender ())
1034
+ if err != nil {
1035
+ t .Fatalf ("Can't create launcher: %v" , err )
1036
+ }
1037
+ defer testLauncher .Close ()
1038
+
1039
+ if err = checkRuntimeStatus (testLauncher .RuntimeStatusChannel (),
1040
+ launcher.RuntimeStatus {RunStatus : & launcher.InstancesStatus {}}, defaultStatusTimeout ); err != nil {
1041
+ t .Errorf ("Check runtime status error: %v" , err )
1042
+ }
1043
+
1044
+ if err = serviceProvider .installServices (testData .services ); err != nil {
1045
+ t .Fatalf ("Can't install services: %v" , err )
1046
+ }
1047
+
1048
+ if err = layerProvider .installLayers (testData .layers ); err != nil {
1049
+ t .Fatalf ("Can't install layers: %v" , err )
1050
+ }
1051
+
1052
+ if err = testLauncher .RunInstances (testData .instances , false ); err != nil {
1053
+ t .Fatalf ("Can't run instances: %v" , err )
1054
+ }
1055
+
1056
+ runtimeStatus := launcher.RuntimeStatus {
1057
+ RunStatus : & launcher.InstancesStatus {Instances : createInstancesStatuses (testData )},
1058
+ }
1059
+
1060
+ if err = checkRuntimeStatus (testLauncher .RuntimeStatusChannel (),
1061
+ runtimeStatus , defaultStatusTimeout ); err != nil {
1062
+ t .Errorf ("Check runtime status error: %v" , err )
1063
+ }
1064
+
1065
+ instanceInfo , err := storage .getInstanceByIdent (testData .instances [0 ].InstanceIdent )
1066
+ if err != nil {
1067
+ t .Fatalf ("Can't get instance: %v" , err )
1068
+ }
1069
+
1070
+ runtimeSpec , err := getInstanceRuntimeSpec (instanceInfo .InstanceID )
1071
+ if err != nil {
1072
+ t .Fatalf ("Can't get instance runtime spec: %v" , err )
1073
+ }
1074
+
1075
+ if * runtimeSpec .Linux .Resources .CPU .Quota != 1000 {
1076
+ t .Errorf ("Wrong CPU quota value: %d" , * runtimeSpec .Linux .Resources .CPU .Quota )
1077
+ }
1078
+ }
1079
+
990
1080
func TestRuntimeEnvironment (t * testing.T ) {
991
1081
layerDigest1 , layerDigest2 , layerDigest3 , layerDigest4 := uuid .NewString (), uuid .NewString (),
992
1082
uuid .NewString (), uuid .NewString ()
0 commit comments